public LoginResponse Login(string userName, string passwrod, string returnUrl, string keepMeSignedIn) { var userData = new LoginResponse(); if (_db.Users.Any(x => x.Username == userName && x.Password == passwrod)) { var user = _db.Users.SingleOrDefault(x => x.Username == userName && x.isActive == "true"); if (user != null) { string Authkey = ConfigurationManager.AppSettings["AuthKey"]; userData.UTMZK = EncryptionClass.GetEncryptionKey(user.Username, Authkey); userData.UTMZV = EncryptionClass.GetEncryptionKey(user.Password, Authkey); userData.TimeStamp = DateTime.Now.ToString(CultureInfo.InvariantCulture); userData.Code = "200"; try { user.KeepMeSignedIn = keepMeSignedIn.Equals("true", StringComparison.OrdinalIgnoreCase)? "true" : "false"; _db.SaveChanges(); } catch (DbEntityValidationException e) { DbContextException.LogDbContextException(e); userData.Code = "500"; return(userData); } } else { userData.Code = "403"; } } else { userData.Code = "401"; } return(userData); }