Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Floral floral = db.Florals.Find(id);

            db.Florals.Remove(floral);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "FloralId,Name,Price,Quantity,Details,Category,Picture")] Floral floral)
 {
     if (ModelState.IsValid)
     {
         db.Entry(floral).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(floral));
 }
Example #3
0
        public ActionResult Create([Bind(Include = "Id,Name,Price,Quantity,Category,Picture")] Floral floral)
        {
            if (ModelState.IsValid)
            {
                db.Florals.Add(floral);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(floral));
        }
Example #4
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Floral floral = db.Florals.Find(id);

            if (floral == null)
            {
                return(HttpNotFound());
            }
            return(View(floral));
        }
        //
        // GET: /Store/AddToCart/5
        public ActionResult AddToCart(int?id, string type)
        {
            Furniture addedFurniture = new Furniture();
            Floral    addedFloral    = new Floral();

            if (Session["productId"] != null && Session["productType"] != null)
            {
                ShoppingCartDetail shoppingCartDetailModel = new ShoppingCartDetail();
                if (Session["productType"].Equals("floral"))
                {
                    int sessionStoredId = (int)Session["productId"];
                    addedFloral = storeDB.Florals
                                  .Single(Floral => Floral.FloralId == sessionStoredId);

                    shoppingCartDetailModel.Name          = addedFloral.Name;
                    shoppingCartDetailModel.Price         = addedFloral.Price;
                    shoppingCartDetailModel.Type          = type;
                    shoppingCartDetailModel.Quantity      = 1;
                    shoppingCartDetailModel.RemainingItem = addedFloral.Quantity - 1;

                    shoppingCartDetailsProductList.Add(shoppingCartDetailModel);
                }
                else if (Session["productType"].Equals("furniture"))
                {
                    int sessionStoredId = (int)Session["productId"];
                    addedFurniture = storeDB.furnitures
                                     .Single(Furniture => Furniture.FurnitureId == sessionStoredId);

                    shoppingCartDetailModel.Name     = addedFurniture.Name;
                    shoppingCartDetailModel.Price    = addedFurniture.Price;
                    shoppingCartDetailModel.Type     = type;
                    shoppingCartDetailModel.Quantity = 1;

                    shoppingCartDetailsProductList.Add(shoppingCartDetailModel);
                }
            }
            else
            {
                Session["productId"]   = id;
                Session["productType"] = type;
            }



            // var addedProduct = new object(); // product can be floral , furniture
            // Retrieve the album from the database

            if (type == "floral")
            {
                ShoppingCartDetail shoppingCartDetailModel = new ShoppingCartDetail();
                addedFloral = storeDB.Florals
                              .Single(Floral => Floral.FloralId == id);

                shoppingCartDetailModel.Name          = addedFloral.Name;
                shoppingCartDetailModel.Price         = addedFloral.Price;
                shoppingCartDetailModel.Type          = type;
                shoppingCartDetailModel.Quantity      = 1;
                shoppingCartDetailModel.RemainingItem = addedFloral.Quantity - 1;

                shoppingCartDetailsProductList.Add(shoppingCartDetailModel);
            }
            else if (type == "furniture")
            {
                ShoppingCartDetail shoppingCartDetailModel = new ShoppingCartDetail();
                addedFurniture = storeDB.furnitures
                                 .Single(Furniture => Furniture.FurnitureId == id);

                shoppingCartDetailModel.Name     = addedFurniture.Name;
                shoppingCartDetailModel.Price    = addedFurniture.Price;
                shoppingCartDetailModel.Type     = type;
                shoppingCartDetailModel.Quantity = 1;

                shoppingCartDetailsProductList.Add(shoppingCartDetailModel);
            }


            //// Add it to the shopping cart
            //var cart = ShoppingCart.GetCart(this.HttpContext);

            //cart.AddToCart(addedProduct); // Not two at a time

            // Go back to the main store page for more shopping
            //  return RedirectToAction("Index")
            return(View("CartIndex", shoppingCartDetailsProductList));
        }