public IHttpActionResult GetProduct(string id) { ProductAPI.core.Entities.Product product = db.GetById(id); if (product == null) { return(NotFound()); } return(Ok(product)); }
public IHttpActionResult PostProduct(ProductAPI.core.Entities.Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Add(product); return(CreatedAtRoute("DefaultApi", new { id = product.ProductID }, product)); }
public IHttpActionResult PutProduct(string id, ProductAPI.core.Entities.Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductID) { return(BadRequest()); } //db.Entry(product).State = EntityState.Modified; db.Edit(product); return(StatusCode(HttpStatusCode.NoContent)); }