public ActionResult DeleteConfirmed(int id) { CartMain cartMain = db.CartMains.Find(id); db.CartMains.Remove(cartMain); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "cart_id,cart_date,user_id,total,Discount,delivery_id")] CartMain cartMain) { if (ModelState.IsValid) { db.Entry(cartMain).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.delivery_id = new SelectList(db.DeliveryDetails, "Id", "billing_first_name", cartMain.delivery_id); return(View(cartMain)); }
public ActionResult Checkout(FormCollection collection) { /* Add your logic for handling the sending of payment to the selected payment gateway. */ ProductDBContext db = new ProductDBContext(); DeliveryDetails deldet = new DeliveryDetails(); deldet.billing_city = collection["billing_city"]; deldet.billing_country = collection["billing_country"]; deldet.billing_email = collection["billing_email"]; deldet.billing_first_name = collection["billing_first_name"]; deldet.billing_last_name = collection["billing_last_name"]; deldet.billing_notes = collection["billing_notes"]; deldet.billing_phone = collection["billing_phone"]; deldet.billing_state = collection["billing_state"]; deldet.billing_stret_1 = collection["billing_stret_1"]; deldet.billing_stret_2 = collection["billing_stret_2"]; deldet.billing_zip = collection["billing_zip"]; deldet.payment_gateway = collection["payment_gateway"]; db.DeliveryDetails.Add(deldet); CartMain main = new CartMain(); main.DeliveryDetails = deldet; main.cart_date = DateTime.Now; main.Discount = 0; db.CartMains.Add(main); CartSub sub = new CartSub(); var cart_items = db.Products.Where(item => SessionSingleton.Current.Cart.Keys.Contains(item.id)); var items = SessionSingleton.Current.Cart; foreach (var item in items) { sub = new CartSub(); var its = item.Value; JavaScriptSerializer js = new JavaScriptSerializer(); var persons = js.Deserialize <ToDoItem>(its); sub.pro_id = item.Key; sub.quantity = persons.quantity; sub.type = persons.type; sub.color = persons.selColor; db.CartSubs.Add(sub); } db.SaveChanges(); SessionSingleton.setclear(); if (deldet.payment_gateway == "paypal") { return(RedirectToAction("PaymentWithPaypal", "Cart")); } return(RedirectToAction("Cash", "Cart")); }
// GET: CartMains/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CartMain cartMain = db.CartMains.Find(id); if (cartMain == null) { return(HttpNotFound()); } return(View(cartMain)); }
// GET: CartMains/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CartMain cartMain = db.CartMains.Find(id); if (cartMain == null) { return(HttpNotFound()); } ViewBag.delivery_id = new SelectList(db.DeliveryDetails, "Id", "billing_first_name", cartMain.delivery_id); return(View(cartMain)); }
private void cart_Click(object sender, RoutedEventArgs e) { var check = this.controlGrid.Children.OfType <CartMain>(); if (check.ToList().Count > 0) { return; } CartMain cartView = new CartMain(); cartView.initData(); this.addUIElement(cartView); this.bringToFront(cartView); }