public async Task <ActionResult> Update([FromRoute] int id, [FromBody] PowerSupplyUpdateDto powerSupply) { _logger.LogForModelUpdate(HttpContext, id); var result = await _powerSuppliesService.UpdatePowerSupplyAsync(id, powerSupply); return(result ? Json(powerSupply) : ResponseResultsHelper.UpdateError()); }
/// <inheritdoc/> public async Task <bool> UpdatePowerSupplyAsync(int id, PowerSupplyUpdateDto powerSupply) { var dataBaseEntity = await _unitOfWorkHardwareAPI.PowerSuppliersRepository.GetByIdAsync(id); if (dataBaseEntity == null) { return(false); } _mapper.Map(powerSupply, dataBaseEntity); var updateResult = await _unitOfWorkHardwareAPI.PowerSuppliersRepository.UpdateAsync(dataBaseEntity); if (!updateResult) { return(false); } return(await _unitOfWorkHardwareAPI.SaveChangesAsync() > 0); }