public async Task <IResult> UpdateAsync(ColorUpdateDto colorUpdateDto) { var ruleResult = BusinessRules.Run(await CheckColorNameExistButIgnoreByIdAsync(colorUpdateDto.Id, colorUpdateDto.Name)); if (!ruleResult.Success) { return(ruleResult); } var findedColor = await _colorDal.GetAsync(p => p.Id == colorUpdateDto.Id); if (findedColor == null) { return(new ErrorResult(Messages.ColorNotFound)); } findedColor.Name = colorUpdateDto.Name; bool updateResult = await _colorDal.UpdateAsync(findedColor); if (!updateResult) { return(new ErrorResult(Messages.ColorNotUpdated)); } return(new SuccessResult(Messages.ColorUpdated)); }
public IResult Update(ColorUpdateDto colorUpdateDto) { //mapping Color color = _mapper.Map <Color>(colorUpdateDto); _colorDal.Update(color); return(new SuccessResult(Messages.ColorDeleted)); }
public IActionResult Update(ColorUpdateDto colorUpdateDto) { var result = _colorService.Update(colorUpdateDto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Update(ColorUpdateDto updateDto) { var result = await _colorService.UpdateAsync(_mapper.Map <Color>(updateDto)); if (result.Success) { return(NoContent()); } return(BadRequest(result)); }
public async Task <IActionResult> UpdateAsync(ColorUpdateDto colorUpdateDto) { var result = await _colorService.UpdateAsync(colorUpdateDto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }