Example #1
0
        public ActionResult Create(int id)
        {
            Table table = tableDb.GetTable(id);

            TempData["TableId"] = id;
            ViewBag.Restaurant  = restDb.GetRestaurant(table.RestaurantId);
            ViewBag.Table       = table;
            CreateReservationsVM vm = new CreateReservationsVM
            {
                Table      = table,
                Restaurant = restDb.GetRestaurant(table.RestaurantId),
            };

            return(View(vm));
        }
Example #2
0
        //Vue complexe utilisant le modèle OrderDetailsViewModel
        //Permet d'afficher le nom du restaurant de la commande, le numéro de la commande, les plats choisis (bug, 1 seul plat est affiché),
        //la quantité par plats, le prix unitaire d'un plat, l'heure de livraison...
        public ActionResult OrderDetails()
        {
            List <OrderDetailsViewModel> listeOrderDetails = new List <OrderDetailsViewModel>();
            OrderDetailsViewModel        orderDetails      = new OrderDetailsViewModel();

            int idCustomer     = HttpContext.Session.GetInt32("IdCustomer").GetValueOrDefault();
            int idOrder        = HttpContext.Session.GetInt32("IdOrder").GetValueOrDefault();
            int idRestaurant   = HttpContext.Session.GetInt32("IdRestaurant").GetValueOrDefault();
            int idDeliveryTime = HttpContext.Session.GetInt32("Id_Delivery_time").GetValueOrDefault();

            OrderManager.UpdateOrderDeliveryTime(idOrder, idDeliveryTime);

            List <DTO.Order_Dish> listeOrder_Dishes = Order_DishManager.GetAllOrder_Dish(idOrder);

            DTO.Customer   customer   = CustomerManager.GetCustomer(idCustomer);
            DTO.Order      order      = OrderManager.GetOrder(idOrder);
            DTO.Restaurant restaurant = RestaurantManager.GetRestaurant(idRestaurant);


            orderDetails.Customers      = customer;
            orderDetails.Orders         = order;
            orderDetails.Restaurants    = restaurant;
            orderDetails.Cities         = CityManager.GetCity(customer.FK_idCity);
            orderDetails.Delivery_Times = Delivery_TimeManager.GetDelivery_Time(idDeliveryTime);

            foreach (DTO.Order_Dish od in listeOrder_Dishes)
            {
                orderDetails.Order_Dishes = od;
                orderDetails.Dishes       = DishManager.GetDish(od.FK_idDish);
            }

            listeOrderDetails.Add(orderDetails);
            return(View(listeOrderDetails));
        }
Example #3
0
        //Show all the dishes of one restaurant
        public ActionResult Details(int id)
        {
            var dishes = DishManager.GetDishes(id);


            ViewBag.nameResto = RestaurantManager.GetRestaurant(id).Name;
            var         cartest  = HttpContext.Session.GetObjectFromJson <List <Cart> >("Cart");
            List <Cart> cartlist = cartest;
            var         cart     = new List <Cart>();

            if (HttpContext.Session.GetObjectFromJson <List <Cart> >("Cart") == null)
            {
            }
            else
            {
                if (!cartlist.Any(m => m.dish.IdRestaurant == id))
                {
                    HttpContext.Session.SetObjectAsJson("Cart", cart);
                }
                else
                {
                    cart = HttpContext.Session.GetObjectFromJson <List <Cart> >("Cart");
                }
            }

            var date         = DateTime.Now;
            var timeDay      = date.TimeOfDay;
            var nextFullHour = TimeSpan.FromHours(Math.Ceiling(timeDay.TotalHours));


            date.AddMinutes(15);

            var dt1      = RoundUp(date, TimeSpan.FromMinutes(15));
            var timeDay2 = dt1.TimeOfDay;


            ViewBag.Time = timeDay2;


            var viewModel = new CartDish();

            viewModel.ListA = dishes;
            viewModel.ListB = cart;
            double price = 0;

            foreach (var plat in viewModel.ListB)
            {
                price += plat.dish.Price;
            }

            viewModel.price = price;

            return(View(viewModel));
        }
Example #4
0
        public ActionResult Delete()
        {
            var        managerId  = User.Identity.GetUserId();
            Restaurant restaurant = db.GetRestaurant(managerId);

            if (restaurant == null)
            {
                return(HttpNotFound());
            }
            return(View(restaurant));
        }
Example #5
0
        public ActionResult CustomerIndex(string id, string search, string category)
        {
            ViewBag.Categories = new SelectList(pcDb.GetProductCategories(), "Name", "Name");
            IndexProductsVM vm = new IndexProductsVM
            {
                Products   = db.GetProducts(id, search, category),
                Search     = search,
                Category   = category,
                Categories = pcDb.GetProductCategories()
            };
            Restaurant restaurant = restDb.GetRestaurant(id);

            ViewBag.Title = $"{restaurant.CompanyName} Menu.";
            return(View(vm));
        }
        //Vue affichant la liste des livraisons affilié à un livreur avec modele DeliveryDetailsViewModel
        public ActionResult ListeDeliverys(int idDeliveryman)
        {
            List <DeliveryDetailsViewModel> listeDelivery = new List <DeliveryDetailsViewModel>();

            idDeliveryman = HttpContext.Session.GetInt32("IdDeliveryman").GetValueOrDefault();
            List <DTO.Delivery> listDeliverys = DeliveryManager.GetAllDelivery(idDeliveryman);

            foreach (DTO.Delivery d in listDeliverys)
            {
                DeliveryDetailsViewModel deliveryDetails = new DeliveryDetailsViewModel();
                deliveryDetails.Deliverys      = d;
                deliveryDetails.Orders         = OrderManager.GetOrder(d.FK_idOrder);
                deliveryDetails.Restaurants    = RestaurantManager.GetRestaurant(d.FK_idRestaurant);
                deliveryDetails.Delivery_Times = Delivery_TimeManager.GetDelivery_Time(d.FK_idDelivery_Time);

                listeDelivery.Add(deliveryDetails);
            }

            return(View(listeDelivery));
        }
Example #7
0
        //Add an item to the shopping cart
        public ActionResult AddItem(int id)
        {
            if (HttpContext.Session.GetObjectFromJson <List <Cart> >("Cart") == null)
            {
                List <Cart> cart = new List <Cart>();
                cart.Add(new Cart {
                    dish = DishManager.GetDish(id), quantity = 1, totalPriceProduct = DishManager.GetDish(id).Price
                });
                HttpContext.Session.SetObjectAsJson("Cart", cart);
            }
            else
            {
                int index = isExist(id);
                if (index != -1)
                {
                    List <Cart> cart = HttpContext.Session.GetObjectFromJson <List <Cart> >("Cart");
                    cart.Select(m => m.dish.IdDish == id);
                    cart[index].quantity++;
                    cart[index].totalPriceProduct += DishManager.GetDish(id).Price;
                    HttpContext.Session.SetObjectAsJson("Cart", cart);
                }
                else
                {
                    List <Cart> cart = HttpContext.Session.GetObjectFromJson <List <Cart> >("Cart");
                    cart.Add(new Cart {
                        dish = DishManager.GetDish(id), quantity = 1, totalPriceProduct = DishManager.GetDish(id).Price
                    });
                    HttpContext.Session.SetObjectAsJson("Cart", cart);
                }
            }

            Dish dish = DishManager.GetDish(id);

            int    idResto = dish.IdRestaurant;
            string name    = RestaurantManager.GetRestaurant(idResto).Name;

            return(RedirectToAction("Details/" + idResto));
        }