public async Task <int> Update(SparePartSoldUpdateDto dto, int id, string userId) { var oldSparePartSold = await _dbContext.SparePartsSold .Include(x => x.Client) .Include(x => x.Motor) .Include(x => x.SalesStaff) .Include(x => x.SalesStaff) .SingleOrDefaultAsync(x => x.Id == id); var updatedSparePartSold = _mapper.Map(dto, oldSparePartSold); _dbContext.SparePartsSold.Update(updatedSparePartSold); await _dbContext.SaveChangesAsync(); return(updatedSparePartSold.Id); }
public async Task <IActionResult> Update([FromBody] SparePartSoldUpdateDto dto, int id) => await GetResponse(async (userId) => new ApiResponseViewModel(true, "SparePartSold Updated Successfully", await _service.Update(dto, id, userId)));