Esempio n. 1
0
        public async Task <IHttpActionResult> Put(SupplierProductBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var supplierProduct = new SupplierProduct
            {
                SupplierId = model.SupplierId,
                ProductId  = model.ProductId,
                Price      = model.Price
            };

            await service.Update(supplierProduct);

            return(Ok());
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Post(SupplierProductBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var supplierProduct = new SupplierProduct
            {
                ProductId  = model.ProductId,
                SupplierId = model.SupplierId,
                Price      = model.Price
            };

            var changes = await service.Save(supplierProduct);

            if (changes == 0)
            {
                return(InternalServerError());
            }
            return(Ok());
        }