Esempio n. 1
0
        public void AddToCart(BeanBag beanBag)
        {
            var cartItem = db.Carts.SingleOrDefault(c => c.CartId == ShoppingCartId && c.BeanBagId == beanBag.id);

            if (cartItem == null)
            {
                cartItem = new Cart
                {
                    BeanBagId = beanBag.id,
                    CartId = ShoppingCartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

                db.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            db.SaveChanges();
        }
        public int createTestObject()
        {
            beanBag = new BeanBag { name = "testObject", beanBagTypeID = 1 };
            order = new Order
            {
                Username = "******",
                FirstName = "TestFirstName",
                LastName = "TestLastName",
                street = "TestStreet",
                hno = "TestHno",
                Zip = "TestZip",
                City = "TestCity",
                Phone = "TestPhone",
                Email = "*****@*****.**",
                Total = 100,
                OrderDate = DateTime.Now
            };

            db.BeanBags.Add(beanBag);
            db.Orders.Add(order);
            //db.Carts.Add(cart);
            db.SaveChanges();

            return beanBag.id;
        }
Esempio n. 3
0
        public void AddToCart(BeanBag beanBag)
        {
            var cartItem = db.Carts.SingleOrDefault(c => c.CartId == ShoppingCartId && c.BeanBagId == beanBag.id);

            if (cartItem == null)
            {
                cartItem = new Cart
                {
                    BeanBagId   = beanBag.id,
                    CartId      = ShoppingCartId,
                    Count       = 1,
                    DateCreated = DateTime.Now
                };

                db.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            db.SaveChanges();
        }
        public int createTestObject()
        {
            beanBag = new BeanBag { name = "testObject", beanBagTypeID = 1 };
            db.BeanBags.Add(beanBag);
            db.SaveChanges();

            return beanBag.id;
        }
        public ActionResult Create(BeanBag beanbag)
        {
            if (ModelState.IsValid)
            {
                db.BeanBags.Add(beanbag);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(beanbag);
        }
        public ActionResult Create(BeanBag beanbag)
        {
            if (ModelState.IsValid)
            {
                db.BeanBags.Add(beanbag);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.beanBagTypeID = new SelectList(db.BeanBagTypes, "id", "name", beanbag.beanBagTypeID);
            return View(beanbag);
        }
 public ActionResult Edit(BeanBag beanbag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(beanbag).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.beanBagTypeID = new SelectList(db.BeanBagTypes, "id", "name", beanbag.beanBagTypeID);
     return View(beanbag);
 }
 public ActionResult Edit(BeanBag beanbag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(beanbag).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(beanbag);
 }