Beispiel #1
0
        public IActionResult ViewCustomerOrders()
        {
            int userId = Convert.ToInt32(TempData["user"]);
            List <Domain.Model.Porder> orders = repository.GetOrders(userId);

            List <PorderModel> orderModels = new List <PorderModel>();

            foreach (Domain.Model.Porder order in orders)
            {
                PorderModel porderModel = new PorderModel();


                porderModel.OrderId   = order.OrderId;
                porderModel.PDate     = order.PDate;
                porderModel.PTime     = order.PTime;
                porderModel.OrderCost = order.OrderCost;


                Domain.Model.Pizza pizza = repository.GetPizza(order.PizzaId);

                porderModel.PType  = pizza.PType;
                porderModel.PSize  = pizza.PSize;
                porderModel.PPrice = pizza.PPrice;
                porderModel.Crust  = pizza.Crust;

                orderModels.Add(porderModel);
            }


            return(View(orderModels));
        }
Beispiel #2
0
        public IActionResult Pizza(int id)
        {
            List <Pizza>                 pizzas      = repository.GetPizzasFromLocation(id);
            List <PizzaModel>            pizzaModels = new List <PizzaModel>();
            List <ToppingsModel>         toppModels  = new List <ToppingsModel>();
            List <Domain.Model.Toppings> toppings    = repository.GetToppings(Convert.ToInt32(id));


            int  userId       = Convert.ToInt32(TempData["user"]);
            bool validateDate = Lib.Handler.OrderHandler.CheckOrderDateTime(repository.GetOrders(),
                                                                            repository.GetLocation(id), repository.GetUser(userId));

            TempData["user"] = userId;

            if (validateDate == true)
            {
                if (pizzas != null)
                {
                    foreach (Domain.Model.Toppings topp in toppings)
                    {
                        ToppingsModel topModel = new ToppingsModel()
                        {
                            TopId  = topp.TopId,
                            TName  = topp.TName,
                            T_Type = topp.T_Type,
                            Cost   = topp.Cost
                        };

                        toppModels.Add(topModel);
                    }

                    foreach (Pizza pizza in pizzas)
                    {
                        PizzaModel pizzaModel = new PizzaModel()
                        {
                            PizzaId     = pizza.PizzaId,
                            PType       = pizza.PType,
                            PSize       = pizza.PSize,
                            Crust       = pizza.Crust,
                            PPrice      = pizza.PPrice,
                            SLocationId = pizza.SLocationId
                        };

                        pizzaModels.Add(pizzaModel);
                    }
                    ViewBag.toppingsModel = toppModels;
                    return(View(pizzaModels));
                }
                else
                {
                }
            }

            return(RedirectToAction("Message"));
        }