public ActionResult <SupplierForViewing> UpdateSupplier(Guid id, SupplierForUpdate supplierForUpdate) { Supplier supplier = _warehouseInventoryRepository.GetSupplier(id); if (supplier == null) { return(NotFound()); } _mapper.Map(supplierForUpdate, supplier); _warehouseInventoryRepository.UpdateSupplier(supplier); _warehouseInventoryRepository.Save(); return(NoContent()); }
public ActionResult <SupplierForViewing> PartialUpdateSupplier(Guid id, JsonPatchDocument <SupplierForUpdate> patchDocument) { Supplier supplier = _warehouseInventoryRepository.GetSupplier(id); if (supplier == null) { return(NotFound()); } SupplierForUpdate supplierForUpdate = _mapper.Map <SupplierForUpdate>(supplier); patchDocument.ApplyTo(supplierForUpdate, ModelState); if (!TryValidateModel(supplierForUpdate)) { return(ValidationProblem(ModelState)); } _mapper.Map(supplierForUpdate, supplier); _warehouseInventoryRepository.Save(); return(NoContent()); }