public int?GetAccountId() { string userName = new Encription().Decrypt(new ApplicationKeys().Key_UserName, _session.GetString("x").ToString()); string password = new Encription().Decrypt(new ApplicationKeys().Key_Password, _session.GetString("y").ToString()); bool IsExisted = _context.Account.Any(x => x.UserName.ToLower().Equals(userName) && x.Password.Equals(password)); if (!IsExisted) { return(null); } Account account = _context.Account.Where(x => x.UserName.ToLower().Equals(userName) && x.Password.Equals(password)).FirstOrDefault(); return(account.AccountId); }
public bool IsAuthenticated(string encriptedUserName, string encriptedPassword, int AccountTypeId) { ApplicationKeys appKeys = new ApplicationKeys(); string decryptedUserName = new Encription().Decrypt(appKeys.Key_UserName, encriptedUserName); string decryptedPassword = new Encription().Decrypt(appKeys.Key_Password, encriptedPassword); bool existedUser = _context.Account.Any(x => x.UserName.ToLower().TrimEnd().Equals(decryptedUserName.ToLower().TrimEnd())); if (existedUser) { int?UserAccountTypeId = _context.Account.Where(x => x.UserName.ToLower().TrimEnd().Equals(decryptedUserName.ToLower().TrimEnd())).FirstOrDefault().AccountTypeId; if (AccountTypeId == UserAccountTypeId) { return(true); } else { return(false); } } else { return(false); } }