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