public async Task <Supplier> Update(int id, DtoSupplierPut dtoSupplierPut) { var supplier = await unitOfWork.Query <Supplier>().FirstOrDefaultAsync(s => s.SupplierID == id); if (supplier == null) { throw new KeyNotFoundException(); } supplier.CompanyName = dtoSupplierPut.CompanyName; supplier.ContactName = dtoSupplierPut.ContactName; supplier.ContactTitle = dtoSupplierPut.ContactTitle; supplier.Address = dtoSupplierPut.Address; supplier.City = dtoSupplierPut.City; supplier.Region = dtoSupplierPut.Region; supplier.PostalCode = dtoSupplierPut.PostalCode; supplier.Country = dtoSupplierPut.Country; supplier.Phone = dtoSupplierPut.Phone; supplier.Fax = dtoSupplierPut.Fax; supplier.HomePage = dtoSupplierPut.HomePage; unitOfWork.Update(supplier); unitOfWork.Commit(); BackgroundJob.Enqueue(() => RefreshCache()); return(supplier); }
public async Task <DtoSupplierGet> PutSupplier(int id, [FromBody] DtoSupplierPut dtoSupplier) { var item = await queryProcessor.Update(id, dtoSupplier); var model = autoMapper.Map <DtoSupplierGet>(item); return(model); }