コード例 #1
0
        public async Task <int> Update(MaintenanceServiceUpdateDto dto, int id, string userId)
        {
            var oldMaintenanceService = await _dbContext.MaintenanceServices
                                        .Include(x => x.Client)
                                        .Include(x => x.Motor)
                                        .Include(x => x.PriceOffer)
                                        .Include(x => x.WorkshopOfficial)
                                        .SingleOrDefaultAsync(x => x.Id == id);

            var updatedMaintenanceService = _mapper.Map(dto, oldMaintenanceService);

            updatedMaintenanceService.UpdateAt  = DateTime.Now;
            updatedMaintenanceService.UpdatedBy = userId;

            _dbContext.MaintenanceServices.Update(updatedMaintenanceService);

            await _dbContext.SaveChangesAsync();

            return(updatedMaintenanceService.Id);
        }
コード例 #2
0
 public async Task <IActionResult> Update([FromBody] MaintenanceServiceUpdateDto dto, int id)
 => await GetResponse(async (userId) =>
                      new ApiResponseViewModel(true, "MaintenanceService Updated Successfully", await _service.Update(dto, id, userId)));