Beispiel #1
0
        public IActionResult PlaceOrder2(CartViewModel cartView)
        {
            PizzaBoxRepository repo = new PizzaBoxRepository();

            UserViewModelClient userViewModelClient = repo.InitUser(TempData["username"] as string, TempData["password"] as string);

            TempData["username"] = userViewModelClient.User.Login.Username;
            TempData["password"] = userViewModelClient.User.Login.Password;

            OrderModel cart;

            XmlSerializer deserializer = new XmlSerializer(typeof(OrderModel));

            using (TextReader tr = new StringReader(TempData["cart"] as string)){
                cart = (OrderModel)deserializer.Deserialize(tr);
            }

            TempData.Keep();
            cart.Store = repo.FindStoreByName(cartView.StoreString);
            cart.PlaceOrder();
            cart.User = userViewModelClient.User;
            repo.PlaceOrder(cart);

            return(View("AddedToCart"));
        }
Beispiel #2
0
        //[InlineData("Pepperoni","HandTossed","Medium","Pepperoni")]
        //[InlineData("Pepperoni","HandTossed","Medium","Pepperoni")]
        public void Test1(string topping, string crust, string size, string name)
        {
            PizzaModel pizza = new PizzaModel();

            pizza.Toppings.Add(new ToppingModel()
            {
                Name = topping
            });
            pizza.Crust = new CrustModel()
            {
                Name = crust
            };
            pizza.Size = new SizeModel()
            {
                Name = size
            };
            pizza.Name = name;

            PizzaBoxRepository repo = new PizzaBoxRepository();

            UserViewModelClient user = repo.InitUser("jpchionglo", "password");

            StoreModel store = repo.FindStoreByName("Oakwood");

            OrderModel order = new OrderModel()
            {
                Pizzas = new System.Collections.Generic.List <PizzaModel>()
                {
                    pizza
                },
                User  = user.User,
                Store = store
            };

            order.PlaceOrder();

            repo.PlaceOrder(order);
        }