public ActionResult LoginPart(string email, string password) { var admin = db.Person.Where(w => w.Email == email || w.Phone == email).FirstOrDefault(); if (admin != null) { string HashPassword = PasswordExtention.HashPassword(password); if (admin.Password == password && (admin.Email == email || admin.Phone == email)) { var adminSession = new SessionKey(); Session[SessionKey.Admin] = email; var x = Session[SessionKey.Admin]; return(RedirectToAction("Index", "Admin")); } else { ViewBag.Login = "******"; return(View()); } } else { ViewBag.Login = "******"; return(View()); } }
public int Register(AccountDTO register) { // convert AccountDTO to Account object using auto mapper register.Password = PasswordExtention.GenerateUserPassword(register.Password); var autoMap = _autoMapper.Map <Account>(register); var result = _accountRepository.Create(autoMap); return(result); }
public int?Login(LoginDTO login) { var account = new Account { Phone = login.Phone, Password = PasswordExtention.GenerateUserPassword(login.Password) }; var result = _accountRepository.Get(account); return(result?.Id); }