public IHttpActionResult PutOnlineCart(int id, OnlineCart onlineCart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != onlineCart.Id) { return(BadRequest()); } db.Entry(onlineCart).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OnlineCartExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetOnlineCart(int id) { OnlineCart onlineCart = db.OnlineCarts.Find(id); if (onlineCart == null) { return(NotFound()); } return(Ok(onlineCart)); }
public IHttpActionResult PostOnlineCart(OnlineCart onlineCart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OnlineCarts.Add(onlineCart); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = onlineCart.Id }, onlineCart)); }
public IHttpActionResult DeleteOnlineCart(int id) { OnlineCart onlineCart = db.OnlineCarts.Find(id); if (onlineCart == null) { return(NotFound()); } db.OnlineCarts.Remove(onlineCart); db.SaveChanges(); return(Ok(onlineCart)); }
public StrategyClient(OnlineCart cart) { this.cart = cart; }