public ActionResult DeleteConfirmed(int id) { CartSub cartSub = db.CartSubs.Find(id); db.CartSubs.Remove(cartSub); db.SaveChanges(); return(RedirectToAction("Index")); }
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")); }
public ActionResult Edit([Bind(Include = "subcr_id,cart_id,pro_id,quantity,type,color,total")] CartSub cartSub) { if (ModelState.IsValid) { db.Entry(cartSub).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.cart_id = new SelectList(db.CartMains, "cart_id", "user_id", cartSub.cart_id); ViewBag.pro_id = new SelectList(db.Products, "id", "name", cartSub.pro_id); return(View(cartSub)); }
// GET: CartSubs/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CartSub cartSub = db.CartSubs.Find(id); if (cartSub == null) { return(HttpNotFound()); } return(View(cartSub)); }
// GET: CartSubs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CartSub cartSub = db.CartSubs.Find(id); if (cartSub == null) { return(HttpNotFound()); } ViewBag.cart_id = new SelectList(db.CartMains, "cart_id", "user_id", cartSub.cart_id); ViewBag.pro_id = new SelectList(db.Products, "id", "name", cartSub.pro_id); return(View(cartSub)); }