Exemplo n.º 1
0
        public IHttpActionResult CreateSupplier(SupplierModel newSupplier)
        {
            var entity = new Supplier {
                Address      = newSupplier.Address,
                City         = newSupplier.City,
                CompanyName  = newSupplier.CompanyName,
                ContactName  = newSupplier.ContactName,
                ContactTitle = newSupplier.ContactTitle,
                Country      = newSupplier.Country,
                Fax          = newSupplier.Fax,
                HomePage     = newSupplier.HomePage,
                Phone        = newSupplier.Phone,
                PostalCode   = newSupplier.PostalCode,
            };

            entity = _repository.CreateSupplier(entity);
            newSupplier.SupplierID = entity.SupplierID;
            String loc = Url.Link("api/suppliers/{supplierID}", new { supplierID = entity.SupplierID });

            return(Created <SupplierModel>(loc, newSupplier));
        }