Beispiel #1
0
        public Account Validate(Account account)
        {
            if (account == null || string.IsNullOrEmpty(account.UserName) || string.IsNullOrEmpty(account.Password))
            {
                return(null);
            }

            var query = $"SELECT * FROM Account WHERE LOWER(UserName) = '{account.UserName.ToLower()}'";
            var data  = _database.ExecuteToTable(query, null, Common.ExecuteTypeEnum.SqlQuery);

            if (data == null || data.Rows.Count <= 0)
            {
                return(null);
            }

            var tempAcc = SqlMapper <Account> .Map(data).FirstOrDefault();

            if (!AccountUtils.VerifyPassword(tempAcc.Password, account.Password))
            {
                return(null);
            }

            return(new Account
            {
                AccountId = tempAcc.AccountId,
                UserName = tempAcc.UserName,
                AccountType = tempAcc.AccountType,
                CreatedDate = tempAcc.CreatedDate
            });
        }