public async Task <IResult> Register(UserForAddUpdateDto user) { byte[] passwordHash, passwordSalt; var mailControl = await this.GetByMail(user.Email); if (mailControl.Success) { if (mailControl.Data != null) { return(new ErrorResult(Messages.UserAlreadyExist)); } else { HashingHelper.CreatePasswordHash(user.Password, out passwordHash, out passwordSalt); var newUser = new User { Email = user.Email, Name = user.Name, Password = passwordHash, PasswordSalt = passwordSalt }; await _userDal.AddAsync(newUser); return(new SuccessResult(Messages.AddedSuccessfully)); } } else { return(new ErrorResult(Messages.SystemError)); } }
public async Task <IActionResult> Update(UserForAddUpdateDto user) { var result = await _userService.Update(user); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IResult> Update(UserForAddUpdateDto user) { var isUserExists = await _userDal.GetAsync(u => u.Id == user.Id); if (isUserExists == null) { return(new ErrorResult(Messages.UserNotFound)); } await _userDal.UpdateAsync(user.Map(isUserExists)); return(new SuccessResult(Messages.UpdatedSuccessfully)); }