public IActionResult Register(RegisterViewModel register) { ViewBag.Email = EmailCleaner.CleanedEmail(register.Email); if (!ModelState.IsValid) { return(View(register)); } if (_userServices.IsExistByEmail(register.Email)) { ModelState.AddModelError("Email", "ایمیل وارد شده قبلا ثبت نام کرده است"); return(View(register)); } var userDTO = _mapper.Map <User>(register); _userServices.AddUser(userDTO); _userServices.SaveChanges(); return(View("SuccessRegister", register)); }
public bool IsExistByEmail(string email) { return(_context.Users.Any(e => e.Email == EmailCleaner.CleanedEmail(email))); }
public User LoginUser(string email, string password) { return(_context.Users.SingleOrDefault(e => e.Email == EmailCleaner.CleanedEmail(email) && e.Password == password)); }