public IActionResult Register(RegisterInputModel model) { if (!ModelState.IsValid) { return(Redirect("/Users/Register")); } if (model.Password != model.ConfirmPassword) { ModelState.Add(string.Empty, "The passwords must match"); return(Redirect("/Users/Register")); } if (usersService.UserExists(model.Username)) { ModelState.Add(string.Empty, "User with the same username already exists!"); return(Redirect("/Users/Register")); } User user = model.MapTo <User>(); string userId = usersService.CreateUser(user); this.SignIn(userId, model.Username, model.Email); return(Redirect("/")); }
public bool Delete(RegisterInputModel registerInputModel) { if (registerInputModel == null) { return(false); } var user = _userRepository.FirstOrDefault(u => u.UserName == registerInputModel.UserName.Trim()); if (user == null) { return(false); } _userRepository.Delete(registerInputModel.MapTo(user)); return(true); }
public bool Modify(RegisterInputModel registerInputModel) { if (registerInputModel == null) { return(false); } var user = _userRepository.FirstOrDefault(u => u.UserName == registerInputModel.UserName.Trim()); if (user == null) { return(false); } registerInputModel.UpdatedTime = DateTime.Now; _userRepository.Update(registerInputModel.MapTo(user)); return(true); }
public bool Register(RegisterInputModel registerInputModel) { if (registerInputModel == null) { return(false); } var user = _userRepository.FirstOrDefault(u => u.UserName == registerInputModel.UserName.Trim()); if (user != null) { return(false); } registerInputModel.UserPassword = registerInputModel.UserPassword.Md5Encryption(); registerInputModel.CreatedTime = registerInputModel.UpdatedTime = DateTime.Now; _userRepository.Add(registerInputModel.MapTo <User>()); return(true); }