Exemplo n.º 1
0
        public ActionResult CancelOrder(OrderDetailViewModel OrderDetailViewModel)
        {
            int accountId = Convert.ToInt32(Session["accountId"]);

            ShoppingCartCSV.CancelOrder(accountId, OrderDetailViewModel.Order.Id);

            return(RedirectToAction("ViewOrderList"));
        }
Exemplo n.º 2
0
        static DateTime deliveryDate = DateTime.Today.AddDays(30); //default

        public ActionResult ViewOrderList()
        {
            var model = new OrderListViewModel
            {
                Orders = ShoppingCartCSV.GetOrders().Where(x => x.AccountId.Equals(123)).ToList()
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult ViewProductDetail(int id)
        {
            var Model = new ProductDetailViewModel
            {
                Product = ShoppingCartCSV.GetProduct(id)
            };

            return(View(Model));
        }
Exemplo n.º 4
0
        public ActionResult ViewProductList(int typeId, int categoryId)
        {
            var model = new ProductListViewModel
            {
                Products = ShoppingCartCSV.GetProducts().Where(x => x.Type.Id.Equals(typeId) && x.Category.Id.Equals(categoryId)).ToList()
            };

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult AddOrder(OrderFormViewModel orderFormViewModel)
        {
            int   accountId = Convert.ToInt32(Session["accountId"]);
            Order order     = orderFormViewModel.Order;
            Cart  cart      = Session["Cart"] as Cart;

            order.Total = cart.Total;

            ShoppingCartCSV.AddOrder(accountId, order, cart);
            Session.Remove("Cart");

            return(RedirectToAction("ViewOrderList"));
        }
Exemplo n.º 6
0
        public ActionResult ViewOrderDetail(int id)
        {
            Order            order      = ShoppingCartCSV.GetOrders().Where(x => x.Id.Equals(id)).FirstOrDefault();
            List <OrderLine> orderLines = ShoppingCartCSV.GetOrderLines().Where(x => x.OrderId.Equals(order.Id)).ToList();

            var model = new OrderDetailViewModel
            {
                Order      = order,
                OrderLines = orderLines
            };

            return(View(model));
        }
Exemplo n.º 7
0
        public ActionResult Index()
        {
            Session["accountId"] = 123; //temporary TODO: replace with retrieve from csv
            List <Product>         products          = ShoppingCartCSV.GetProducts();
            List <ProductCategory> productCategories = ShoppingCartCSV.GetProductCategories().OrderBy(x => x.Name).ToList();
            List <ProductType>     productTypes      = ShoppingCartCSV.GetProductTypes().OrderBy(x => x.Name).ToList();


            var model = new HomeViewModel
            {
                ProductCategories = productCategories,
                ProductTypes      = productTypes,
                Products          = products
            };

            return(View(model));
            //return RedirectToAction("ViewProducts", "Product", null);
        }
Exemplo n.º 8
0
        public ActionResult AddToCart(ProductDetailViewModel ProductDetailViewModel)
        {
            if (ProductDetailViewModel.Quantity < 1)
            {
                return(RedirectToAction("ViewCart"));
            }
            else
            {
                var product  = ShoppingCartCSV.GetProduct(ProductDetailViewModel.Product.Id);
                var quantity = ProductDetailViewModel.Quantity;

                Item item = new Item
                {
                    Product  = product,
                    Quantity = quantity
                };

                this.SetSession("Cart");

                var v = cart.Items.FirstOrDefault(x => x.Product.Id.Equals(product.Id));

                if (v == null)
                {
                    cart.Items.Add(item);
                }
                else
                {
                    v.Quantity += quantity;
                }


                Session.Add("Cart", cart);

                return(RedirectToAction("ViewCart"));
            }
        }