public async Task <int> Update(MaintenanceContractUpdateDto dto, int id, string userId) { var oldMaintenanceContract = await _dbContext.MaintenanceContracts .Include(x => x.Client) .Include(x => x.Motor) .Include(x => x.MaintenanceCycles) .SingleOrDefaultAsync(x => x.Id == id); var updatedMaintenanceContract = _mapper.Map(dto, oldMaintenanceContract); updatedMaintenanceContract.UpdateAt = DateTime.Now; updatedMaintenanceContract.UpdatedBy = userId; _dbContext.MaintenanceContracts.Update(updatedMaintenanceContract); await _dbContext.SaveChangesAsync(); return(updatedMaintenanceContract.Id); }
public async Task <IActionResult> Update([FromBody] MaintenanceContractUpdateDto dto, int id) => await GetResponse(async (userId) => new ApiResponseViewModel(true, "MaintenanceContract Updated Successfully", await _service.Update(dto, id, userId)));