public void PostProducts(Products products) { db.Entry(products).State = EntityState.Added; try { //db.Products.Add(products); db.SaveChanges(); } catch (Exception) { throw; } }
public IHttpActionResult PutProducts(int id, Products products) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != products.p_id) { return(BadRequest()); } db.Entry(products).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }