Exemple #1
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));
        }
Exemple #2
0
        public void GetAddresses_GetsBuyersAddresses_ListAddresses()
        {
            Buyer newBuyer = new Buyer("username", "phone", "email", "password", "creditCard");

            newBuyer.Save();

            Address one = new Address(newBuyer.GetId(), "street", "name", "city", "state", "country", "zip");
            Address two = new Address(newBuyer.GetId(), "street2", "name2", "city2", "state2", "country2", "zip2");

            one.Save();
            two.Save();

            List <Address> expected = new List <Address> {
                one, two
            };
            List <Address> actual = newBuyer.GetAddresses();

            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #3
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));
        }