Example #1
0
        public ActionResult BuyerCart(int productId, int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object> {
            };
            Buyer selectedBuyer = Buyer.Find(id);

            string itemSize  = Request.Form["size-select"];
            string itemColor = Request.Form["colors"];
            int    quantity  = int.Parse(Request.Form["quantity"]);

            Item  newItem = new Item(itemSize, itemColor, productId);
            Order myOrder = selectedBuyer.GetCurrentOrder();

            for (var i = 0; i < quantity; i++)
            {
                newItem.Save();
                myOrder.AddItem(newItem.GetId());
            }

            model.Add("categories", Category.GetAll());
            model.Add("buyer", selectedBuyer);
            model.Add("items", selectedBuyer.GetCurrentOrder().GetItems());
            model.Add("order", myOrder);

            return(View("Cart", model));
        }
Example #2
0
        public ActionResult IndexPopulate()
        {
            Category.DeleteAll();
            Buyer.DeleteAll();

            Populate.PopulateDatabase();
            Dictionary <string, object> model = new Dictionary <string, object> {
            };

            Buyer          buyer    = Buyer.Find(0);
            List <Product> featured = Product.GetAll();

            Random         rnd         = new Random();
            List <Product> newFeatured = new List <Product>()
            {
            };

            if (featured.Count > 0)
            {
                for (var i = 0; i < 4; i++)
                {
                    newFeatured.Add(featured[rnd.Next(0, (featured.Count - 1))]);
                }
                var featuredProduct = featured[rnd.Next(0, (featured.Count - 1))];
                model.Add("featured", featuredProduct);
            }

            model.Add("categories", Category.GetAll());
            model.Add("buyer", buyer);
            model.Add("products", newFeatured);

            return(View("Index", model));
        }
Example #3
0
        public ActionResult BuyerForm()
        {
            Buyer buyer = Buyer.Find(0);
            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();

            Model.Add("categories", allCategories);
            Model.Add("buyer", buyer);
            return(View(Model));
        }
Example #4
0
        public void Find_FindsBuyerInDatabaseById_Buyer()
        {
            Buyer expected = new Buyer("username", "phone", "email", "password", "creditCard");

            expected.Save();

            Buyer actual = Buyer.Find(expected.GetId());

            Assert.AreEqual(expected, actual);
        }
Example #5
0
        public ActionResult updateBuyerInfo(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object> {
            };
            Buyer selectedBuyer = Buyer.Find(id);

            // model.Add("products", buyerProducts);
            model.Add("categories", Category.GetAll());
            model.Add("buyer", selectedBuyer);

            return(View("updateBuyerInfo", model));
        }
Example #6
0
        public ActionResult LogIn()
        {
            Dictionary <string, object> model = new Dictionary <string, object> {
            };
            Buyer selectedBuyer = Buyer.Find(0);

            // model.Add("products", buyerProducts);
            model.Add("categories", Category.GetAll());
            model.Add("buyer", selectedBuyer);
            model.Add("login", " ");

            return(View(model));
        }
Example #7
0
        public void Update_UpdateProperties_Buyer()
        {
            Buyer newBuyer = new Buyer("username", "phone", "email", "password", "creditCard");

            newBuyer.Save();

            newBuyer.Update("username2", "phone2", "email2", "password2", "2222-222-222");

            Buyer expected = newBuyer;
            Buyer actual   = Buyer.Find(newBuyer.GetId());

            Assert.AreEqual(expected, actual);
        }
Example #8
0
        public ActionResult UpdateBuyerInfoForm(int id)
        {
            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();
            List <Product> allProducts        = Product.GetAll();
            Buyer          newBuyer           = Buyer.Find(id);
            List <Order>   OrdersForThisBuyer = newBuyer.GetOrderHistory();

            Model.Add("categories", allCategories);
            Model.Add("buyer", newBuyer);
            Model.Add("products", allProducts);
            Model.Add("orders", OrdersForThisBuyer);
            return(View("UpdateBuyerInfo", Model));
        }
Example #9
0
        public ActionResult BuyerDetail(int id)
        {
            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();
            List <Address> addresses = new List <Address>();

            Buyer        selectedBuyer      = Buyer.Find(id);
            List <Order> OrdersForThisBuyer = selectedBuyer.GetOrderHistory();

            Model.Add("orders", OrdersForThisBuyer);
            Model.Add("addresses", selectedBuyer.GetAddresses());
            Model.Add("buyer", selectedBuyer);
            Model.Add("categories", allCategories);
            return(View(Model));
        }
Example #10
0
        public ActionResult Cart(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object> {
            };
            Buyer       selectedBuyer         = Buyer.Find(id);
            Order       buyerOrder            = selectedBuyer.GetCurrentOrder();
            List <Item> buyerItems            = buyerOrder.GetItems();

            model.Add("order", buyerOrder);
            model.Add("items", buyerItems);
            // model.Add("products", buyerProducts);
            model.Add("categories", Category.GetAll());
            model.Add("buyer", selectedBuyer);
            return(View(model));
        }
Example #11
0
        public ActionResult ProductDetails(int prodId, int buyerId)
        {
            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();

            Model.Add("categories", allCategories);
            Buyer newBuyer = Buyer.Find(buyerId);

            Model.Add("buyer", newBuyer);
            Product newProduct = Product.Find(prodId);

            Model.Add("product", newProduct);
            Model.Add("items", newProduct.GetItems());
            return(View(Model));
        }
Example #12
0
        public ActionResult CategorySort(int catId, int buyerId)
        {
            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();
            List <Product> allProducts = Product.GetAll();
            Buyer          newBuyer    = Buyer.Find(buyerId);

            string sortParameter = Request.Form["sort"];

            Model.Add("categories", allCategories);
            Model.Add("selectedCategory", Category.Find(catId));
            Model.Add("products", allProducts);
            Model.Add("buyer", newBuyer);
            Model.Add("sortParameter", sortParameter);
            return(View("Category", Model));
        }
Example #13
0
        public ActionResult SearchResults(int id)
        {
            string         searchString  = Request.Form["searchtext"];
            List <Product> searchResults = Product.Search(searchString);

            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();


            Buyer selectedBuyer = Buyer.Find(id);

            Model.Add("buyer", selectedBuyer);
            Model.Add("categories", allCategories);
            Model.Add("searchResults", searchResults);
            Model.Add("searchString", searchString);
            return(View(Model));
        }
Example #14
0
        public ActionResult Receipt(int orderId, int buyerId)
        {
            Dictionary <string, object> model = new Dictionary <string, object> {
            };
            Buyer selectedBuyer = Buyer.Find(buyerId);

            // model.Add("products", buyerProducts);
            model.Add("categories", Category.GetAll());
            model.Add("buyer", selectedBuyer);
            model.Add("order", Order.Find(orderId));
            model.Add("address", Address.Find(int.Parse(Request.Form["address-select"])));
            Order.Find(orderId).Purchase();
            Order newOrder = new Order(selectedBuyer.GetId(), (DateTime.Now), false);

            newOrder.Save();

            return(View(model));
        }
Example #15
0
        public ActionResult UpdateBuyerInfo(int id)
        {
            Dictionary <string, object> Model         = new Dictionary <string, object>();
            List <Category>             allCategories = Category.GetAll();
            Buyer  newBuyer   = Buyer.Find(id);
            string name       = Request.Form["buyer-name"];
            string password   = Request.Form["buyer-password"];
            string phone      = Request.Form["buyer-phone"];
            string email      = Request.Form["buyer-email"];
            string cardNumber = Request.Form["buyer-card-number"];

            newBuyer.Update(name, phone, email, password, cardNumber);
            List <Order> OrdersForThisBuyer = newBuyer.GetOrderHistory();

            Model.Add("orders", OrdersForThisBuyer);
            Model.Add("categories", allCategories);
            Model.Add("buyer", newBuyer);
            Model.Add("addresses", newBuyer.GetAddresses());
            return(View("BuyerDetail", Model));
        }
Example #16
0
        public ActionResult CartSingleRemove(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object> {
            };

            Buyer selectedBuyer = Buyer.Find(id);
            Order buyerOrder    = selectedBuyer.GetCurrentOrder();


            selectedBuyer.GetCurrentOrder().RemoveItem(int.Parse(Request.Form["item-id"]));
            List <Item> buyerItems = buyerOrder.GetItems();

            model.Add("order", buyerOrder);
            model.Add("items", buyerItems);
            // model.Add("products", buyerProducts);
            model.Add("categories", Category.GetAll());
            model.Add("buyer", selectedBuyer);


            return(View("Cart", model));
        }