Example #1
0
        public IActionResult Order(int pizzaId)
        {
            Domain.Model.Pizza     pizza    = repository.GetPizza(1);
            Domain.Model.Plocation location = repository.GetLocation(pizza.SLocationId);

            if (pizza != null)
            {
                orderModel = new PorderModel();


                orderModel.PDate       = DateTime.Now.ToString("M/d/yyyy");
                orderModel.PTime       = DateTime.Now.ToShortTimeString();
                orderModel.PType       = pizza.PType;
                orderModel.PSize       = pizza.PSize;
                orderModel.Crust       = pizza.Crust;
                orderModel.PUserId     = Convert.ToInt32(TempData["user"]);
                orderModel.PizzaId     = pizza.PizzaId;
                orderModel.OrderCost   = "57.67";
                orderModel.PPrice      = pizza.PPrice;
                orderModel.CLocationId = location.LocationId;
                orderModel.Street      = location.Street;
                orderModel.City        = location.City;
                orderModel.PState      = location.PState;
                orderModel.Zipcode     = location.Zipcode;

                return(View(orderModel));
            }

            return(View());
        }
Example #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"));
        }