public async Task <ActionResult> Update([FromRoute] int id, [FromBody] ProducerUpdateDto producer) { _logger.LogForModelUpdate(HttpContext, id); var result = await _producersService.UpdateProducerAsync(id, producer); return(result ? Json(producer) : ResponseResultsHelper.UpdateError()); }
/// <inheritdoc/> public async Task <bool> UpdateProducerAsync(int id, ProducerUpdateDto producer) { var dataBaseEntity = await _unitOfWorkHardwareAPI.ProducersRepository.GetByIdAsync(id); if (dataBaseEntity == null) { return(false); } _mapper.Map(producer, dataBaseEntity); await _unitOfWorkHardwareAPI.ProducersRepository.UpdateAsync(dataBaseEntity); return(await _unitOfWorkHardwareAPI.SaveChangesAsync() > 0); }