Esempio n. 1
0
        public ActionResult Order(Purchas purchas)
        {
            if (ModelState.IsValid)
            {
                List <ShopingCart> cart = (List <ShopingCart>)Session["Cart"];
                Purchas            puch = new Purchas();
                if (cart == null)
                {
                    return(Content("<h1> К сожалению ваша корзина пуста </h1>"));
                }

                else
                {
                    for (int i = 0; i < cart.Count; i++)
                    {
                        purchas.IdProducts = cart[i].product.Id;
                        //может добавлю название книги
                        purchas.Data = DateTime.Today;
                        db.Purchases.Add(purchas);

                        db.SaveChanges();
                    }
                }
                FlashMessage.Confirmation("Спасибо за покупку");
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
Esempio n. 2
0
        public ActionResult OrderFast(Purchas purchas, int id)
        {
            if (ModelState.IsValid)
            {
                if (id != 0)
                {
                    purchas.Data       = DateTime.Today;
                    purchas.IdProducts = id;
                    db.Purchases.Add(purchas);
                    db.SaveChanges();

                    FlashMessage.Confirmation("Спасибо за покупку");
                    return(RedirectToAction("Index", "Home"));
                }
            }

            return(RedirectToAction("Order", "Shoping"));
        }