public bool SaveUser(User entity) { var _entity = new SecureChat.DAL.User { Id = entity.Id, UserName = entity.Email, FirstName = entity.FirstName, LastName = entity.LastName, BirthDate = entity.BirthDate, Sex = entity.Sex, City = entity.City, Address = entity.Address, PasswordHash = entity.PasswordHash, Email = entity.Email, IsDeleted = entity.IsDeleted }; var resultUser = repository.GetByEmail(_entity); if (resultUser == null) { entity.RegistrationDate = DateTime.Now; return(repository.Save(_entity)); } return(false); }
public async Task <IActionResult> Login(UserLoginModel userLogin) { UserBL userBl = new UserBL(_uow.userRepository); if (ModelState.IsValid) { var user = new SecureChat.DAL.User { Email = userLogin.Email, PasswordHash = userLogin.Password, }; var FindUser = _uow.userRepository.GetByEmail(user); if (FindUser != null && FindUser.IsDeleted == false) { await _uow.signInManager.SignOutAsync(); var result = _uow.signInManager.PasswordSignInAsync(FindUser, user.PasswordHash, true, false).Result; if (result.Succeeded) { return(Redirect("/Chat/Index")); } } ModelState.AddModelError(nameof(userLogin.Email), "Invalid user or password"); } return(RedirectToAction("Login")); }
public bool Update(User entity) { var _entity = new SecureChat.DAL.User { Id = entity.Id, UserName = entity.Email, FirstName = entity.FirstName, LastName = entity.LastName, BirthDate = entity.BirthDate, Sex = entity.Sex, City = entity.City, Address = entity.Address, PasswordHash = entity.PasswordHash, Email = entity.Email, IsDeleted = entity.IsDeleted }; return(repository.Update(_entity)); }