public IHttpActionResult PutTblcart(int id, Tblcart tblcart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblcart.cartID) { return(BadRequest()); } db.Entry(tblcart).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TblcartExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostTblcart(Tblcart tblcart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Tblcarts.Add(tblcart); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblcart.cartID }, tblcart)); }
public IHttpActionResult DeleteTblcart(int id) { Tblcart tblcart = db.Tblcarts.Find(id); if (tblcart == null) { return(NotFound()); } db.Tblcarts.Remove(tblcart); db.SaveChanges(); return(Ok(tblcart)); }