示例#1
0
        //public ActionResult Sepet()
        //{
        //    return View();
        //}


        // GET: NewUrunler/Details/5
        public ActionResult Sepet(int?id)

        {
            var sepetoturum = db.SepetOturumlar.FirstOrDefault(x => x.durum == 0);

            if (sepetoturum == null)
            {
                sepetoturum = new SepetOturum
                {
                    durum = 0,
                    tarih = DateTime.Now
                };
                db.SepetOturumlar.Add(sepetoturum);
                db.SaveChanges();
            }
            sepetoturum.Sepets.Add(new Models.Sepet {
                durum = 1, urunid = id.Value, sepetoturumid = sepetoturum.sepetoturumid
            });
            db.SaveChanges();

            return(RedirectToAction("Index"));


            /*  if (Session["sepet"] == null)
             * {
             *    List<Item> cart = new List<Item>();
             *    cart.Add(new Item(db.Urunler.Find(id), 1));
             *    Session["sepet"] = cart;
             * }
             * else
             * {
             *    List<Item> cart = (List<Item>)Session["sepet"];
             *    int index = isExisting(id);
             *    if (index == -1)
             *        cart.Add(new Item(db.Urunler.Find(id), 1));
             *    else
             *        cart[index].Quantity++;
             *    Session["sepet"] = cart;
             *
             * }
             * return View("Sepet");*/
        }
示例#2
0
        // GET: Satis
        public ActionResult Index()
        {
            var sepetoturum = db.SepetOturumlar.FirstOrDefault(x => x.durum == 0);

            if (sepetoturum == null)
            {
                sepetoturum = new SepetOturum
                {
                    durum = 0,
                    tarih = DateTime.Now
                };
                db.SepetOturumlar.Add(sepetoturum);
                db.SaveChanges();
            }
            if (sepetoturum.Sepets == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(sepetoturum));
        }