// Copyright 2018 RED Software, LLC. All Rights Reserved.

using IgniteEngine;

namespace LoginServer.Services
{
    internal class AccountService
    {
        internal static void Login(string userName, string password, out int userNo, out bool blocked, out bool canLogin)
        {
            using (var usp_User_loginGame = new StoredProcedure("usp_User_loginGame", Program.ODBC))
            {
                usp_User_loginGame.AddParameter("userID", userName, 20);
                usp_User_loginGame.AddParameter("userPW", password, 32);

                usp_User_loginGame.AddOutput<int>("userNo");
                usp_User_loginGame.AddOutput<byte>("authID");
                usp_User_loginGame.AddOutput<int>("block");
                usp_User_loginGame.AddOutput<int>("canLogin");

                usp_User_loginGame.Run();

                userNo = usp_User_loginGame.GetOutput<int>("userNo");
                blocked = usp_User_loginGame.GetOutput<int>("block") == 1;
                canLogin = usp_User_loginGame.GetOutput<int>("canLogin") == 1;
            }
        }
    }
}
