using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Villain.Data.Types;
using Villain.Databases;

namespace Fiesta.Databases.Account.StoredProcedures
{
	public class usp_User_loginGame_US
	{
		public Int32 UserNo;
		public byte AuthID;
		public Int32 Block;
		public Int32 IsLoginable;

		public usp_User_loginGame_US(string userID, string userPW)
		{
			SQLServer sqlServer = DatabaseManager.Get<SQLServer>("Account");
			
			userID = userID.Truncate(260);
			userPW = userPW.Truncate(32);

			SqlCommand command = sqlServer.StoredProcedure(
				"usp_User_loginGame_US",
				new SqlParameter[]
				{
					new SqlParameter("@userID", userID),
					new SqlParameter("@userPW", userPW),

					new SqlParameter("@userNo", SqlDbType.Int){
						Direction = ParameterDirection.Output
					},
					new SqlParameter("@authID", SqlDbType.TinyInt){
						Direction = ParameterDirection.Output
					},
					new SqlParameter("@block", SqlDbType.Int){
						Direction = ParameterDirection.Output
					},
					new SqlParameter("@isLoginable", SqlDbType.Int){
						Direction = ParameterDirection.Output
					}
				}
			);

			command.ExecuteNonQuery();

			command.TryParse("@userNo", out UserNo);
			command.TryParse("@authID", out AuthID);
			command.TryParse("@block", out Block);
			command.TryParse("@isLoginable", out IsLoginable);
		}
	}
}