Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }