Example #1
0
        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());
        }
Example #2
0
        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());
        }