Esempio n. 1
0
 public ActionResult Index(string id)
 {
     using (var context = new ShopContainer())
     {
         var model = new SiteModel(context, id??"");
         ViewBag.IsHomePage = model.IsHomePage;
         ViewBag.MainMenu = model.Menu;
         ViewBag.CatalogueMenu = model.CatalogueMenu;
         this.SetSeoContent(model);
         //ViewBag.CurrentMenuItem = model.Content.Name;
         return View(model);
     }
 }
Esempio n. 2
0
        //
        // GET: /Cart/

        public ActionResult Index()
        {
            if (WebSession.OrderItems.Count == 0)
                return RedirectToAction("Index", "Home", null);


            using (var context = new ShopContainer())
            {
                decimal totalAmount = WebSession.OrderItems.Sum(oi => oi.Value.Price * oi.Value.Quantity);
                ViewData["totalAmount"] = totalAmount;

                var model = new SiteModel(context, null);
                ViewBag.MainMenu = model.Menu;
                ViewBag.CatalogueMenu = model.CatalogueMenu;
                model.Title += " Корзина";
                this.SetSeoContent(model);
                return View(model);
            }
        }
Esempio n. 3
0
 public ActionResult CheckOut()
 {
     using (var context = new ShopContainer())
     {
         var model = new SiteModel(context, null);
         ViewBag.MainMenu = model.Menu;
         ViewBag.CatalogueMenu = model.CatalogueMenu;
         model.Title += " - Оформление заказа";
         this.SetSeoContent(model);
         return View(model);
     }
 }
Esempio n. 4
0
        public ActionResult CheckOut(FormCollection form)
        {
            using (var context = new ShopContainer())
            {
                Order order = new Order
                {
                    DeliveryAddress = form["Order.DeliveryAddress"],
                    Email = form["Order.Email"],
                    Name = form["Order.Name"],
                    OrderDate = DateTime.Now,
                    Phone = form["Order.Phone"],
                    Complited = false
                };

                foreach (var orderItem in WebSession.OrderItems.Select(o => o.Value))
                {
                    order.OrderItems.Add(orderItem);
                }


                if (order.OrderItems.Any())
                {
                    context.AddToOrder(order);
                    context.SaveChanges();
                    SendEmail(order);
                    WebSession.OrderItems.Clear();
                }

                using (var siteContext = new ShopContainer())
                {
                    var model = new SiteModel(siteContext, null);
                    ViewBag.MainMenu = model.Menu;
                    ViewBag.CatalogueMenu = model.CatalogueMenu;
                    model.Title += " - Ваш заказ оформлен";
                    this.SetSeoContent(model);
                    return View("ThankYou", model);
                }
            }

        }