// DELETE: api/Cart/5 public void Delete(int id) { T_Cart data = cartobj.T_Cart.Find(id); cartobj.T_Cart.Remove(data); cartobj.SaveChanges(); }
public bool InsertCart(int mid, decimal price, int number, int pid) { T_Cart cart = new T_Cart(); T_Protuct produce = new T_Protuct(); T_ProductDetail pdetail = new T_ProductDetail(); UserBll userbll = new UserBll(); cart.CreateDate = DateTime.Now; cart.ProductPrice = price; cart.ProductNumber = number; cart.ProductdetailId = mid; cart.ProductId = pid; cart.UserId = userbll.GetUserIdByToken(); ProductBll pbll = new ProductBll(); CartDal cartdal = new CartDal(); produce = pbll.GetProductById(pid); pdetail = pbll.GetPDetailById(mid); if (pdetail != null) { cart.Specification = pdetail.Specification; cart.Size = pdetail.Size; } if (produce != null) { cart.ProductName = produce.ProductTitle; cart.ImgUrl = produce.Imgurl1; // cart.Specification=produce.sp } return(cartdal.InsertCart(cart)); }
public bool InsertCart(T_Cart model) { using (var db = new cakedbEntities()) { db.Set <T_Cart>().Add(model); return(db.SaveChanges() > 0); } }
// PUT: api/Cart/5 public void Put(int id, [FromBody] T_Cart c) { T_Cart c1 = cartobj.T_Cart.Find(id); c1.UserId = c.UserId; c1.SeatId = c.SeatId; c1.Quantity = c.Quantity; c1.Price = c.Price; cartobj.SaveChanges(); }
public void Add(T_Cart cart) { T_Cart cart1 = new T_Cart(); cart1.Price = 150; cart1.UserId = cart.UserId; cart1.SeatId = cart.SeatId; cart1.Quantity = 1; cartobj.T_Cart.Add(cart1); cartobj.SaveChanges(); }