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