public ActionResult Post([FromBody]ProductEdit model) { Product newProduct = new Product() { Description = model.Description, SalesPrice = model.SalesPrice, CostPrice = model.CostPrice }; _ctx.Product.Add(newProduct); if(_ctx.SaveChanges() > 0) { return new CreatedResult($"api/product/{newProduct.Id}", newProduct); } else { return new BadRequestObjectResult(model); } }
public ActionResult Post([FromBody] CustomerEdit model) { Customer newCustomer = new Customer() { Title = model.Title, Firstname = model.Firstname, Lastname = model.Lastname, DateOfBirth = model.DateOfBirth, Address = model.Address, Country = model.Country, PostalCode = model.PostalCode }; _ctx.Customer.Add(newCustomer); if (_ctx.SaveChanges() > 0) { return(new CreatedResult($"api/customer/{newCustomer.Id}", newCustomer)); } else { return(new BadRequestObjectResult(model)); } }