public ActionResult Details(int id)
        {
            //creation of multiple variables to check conditions and for the display
            IOrderDB               order             = new OrderDB(Configuration);
            IOrderManager          om                = new OrderManager(order);
            ICustomerDB            customer          = new CustomerDB(Configuration);
            ICustomerManager       cm                = new CustomerManager(customer);
            ICityDB                citydb            = new CityDB(Configuration);
            ICityManager           cityman           = new CityManager(citydb);
            IDelivery_staffDB      dsDB              = new Delivery_staffDB(Configuration);
            IDelivery_staffManager dsM               = new Delivery_staffManager(dsDB);
            IDishDB                dish              = new DishDB(Configuration);
            IDishManager           dishManager       = new DishManager(dish);
            IOrder_dishesDB        order_Dishes      = new Order_dishesDB(Configuration);
            IOrder_dishesManager   odm               = new Order_dishesManager(order_Dishes);
            IRestaurantDB          restaurant        = new RestaurantDB(Configuration);
            IRestaurantManager     restaurantManager = new RestaurantManager(restaurant);

            //Creations of multiple ViewData for the display
            var customerlist = cm.GetCustomers();

            ViewData["Customers"] = customerlist;
            var citylist = cityman.GetCities();

            ViewData["City"] = citylist;
            var allOrders = om.GetOrders();

            ViewData["AllOrders"] = allOrders;
            var allStaff = dsM.GetDelivery_staffs();

            ViewData["AllStaffs"] = allStaff;
            var allDishes = dishManager.GetAllDishes();

            ViewData["AllDishes"] = allDishes;
            var allOrderDishes = odm.GetAllOrders_dishes();

            ViewData["AllOrderDishes"] = allOrderDishes;
            var allRestaurants = restaurantManager.GetRestaurants();

            ViewData["AllRestaurants"] = allRestaurants;

            ViewBag.nameDL = HttpContext.Session.GetString("nameDL");
            var od = om.GetOrders_ds(id); //Get all orders according to the deliverer's id

            List <Order> odtrie = new List <Order>();

            //Creation of a list which will only contain the non delivery order(s)
            foreach (Order o in od)
            {
                if (o.status.Equals("non delivery"))
                {
                    odtrie.Add(o);
                }
            }

            return(View(odtrie)); //Display the non delivery order(s)
        }
Esempio n. 2
0
        // GET: Customer/Details/5
        public ActionResult Details()
        {
            if ((string)HttpContext.Session.GetString("login") != "Aucun customer n'est log" && (string)HttpContext.Session.GetString("login") != null) // A customer is logged ?
            {
                //Get the login of the current customer
                ViewBag.login = HttpContext.Session.GetString("login");

                //creation of multiple variables to check conditions and for the display
                IOrderDB               order           = new OrderDB(Configuration);
                IOrderManager          om              = new OrderManager(order);
                IDelivery_staffDB      dsDB            = new Delivery_staffDB(Configuration);
                IDelivery_staffManager dsM             = new Delivery_staffManager(dsDB);
                IDishDB              dish              = new DishDB(Configuration);
                IDishManager         dishManager       = new DishManager(dish);
                IOrder_dishesDB      order_Dishes      = new Order_dishesDB(Configuration);
                IOrder_dishesManager odm               = new Order_dishesManager(order_Dishes);
                IRestaurantDB        restaurant        = new RestaurantDB(Configuration);
                IRestaurantManager   restaurantManager = new RestaurantManager(restaurant);

                //Get the id of the current customer
                var id = (int)HttpContext.Session.GetInt32("id");

                //Get an orderlist according to the customer id
                var ordersList = om.GetOrders(id);

                //Creations of multiple ViewData for the display
                var allOrders = om.GetOrders();
                ViewData["AllOrders"] = allOrders;
                var allStaff = dsM.GetDelivery_staffs();
                ViewData["AllStaffs"] = allStaff;
                var allDishes = dishManager.GetAllDishes();
                ViewData["AllDishes"] = allDishes;
                var allOrderDishes = odm.GetAllOrders_dishes();
                ViewData["AllOrderDishes"] = allOrderDishes;
                var allRestaurants = restaurantManager.GetRestaurants();
                ViewData["AllRestaurants"] = allRestaurants;

                //Check if the customer has not order
                if (ordersList == null)
                {
                    return(RedirectToAction("DetailsNoOrder", "Customer", new { user = id.ToString() }));
                }
                else
                {
                    return(View(ordersList)); // Return the Details view
                }
            }
            else
            {
                return(RedirectToAction("Index", "Customer")); // return to the login page
            }
        }
Esempio n. 3
0
        //Display the dish(es) in a specific order
        public ActionResult DishesInOrder(int id)
        {
            IDishDB      dish        = new DishDB(Configuration);
            IDishManager dishManager = new DishManager(dish);

            IOrder_dishesDB      order_Dishes = new Order_dishesDB(Configuration);
            IOrder_dishesManager odm          = new Order_dishesManager(order_Dishes);

            //Creation of a ViewData for the display
            var allDishes = dishManager.GetAllDishes();

            ViewData["AllDishes"] = allDishes;


            var orderDishes = odm.GetOrders_dishes(id);

            return(View(orderDishes)); //Display the list of dish(es)
        }
        public static void Suite(int idCustomer)
        {
            var restaurantDbManager    = new RestaurantManager(Configuration);
            var dishDbManager          = new DishManager(Configuration);
            var delivery_TimeDbManager = new Delivery_TimeManager(Configuration);
            var orderDbManager         = new OrderManager(Configuration);
            var customerDbManager      = new CustomerManager(Configuration);
            var deliveryDbManager      = new DeliveryManager(Configuration);
            var orderDishDbManager     = new Order_DishManager(Configuration);
            var deliverymanDbMangager  = new DeliverymanManager(Configuration);

            Console.WriteLine("[1] New order, [2] Cancel order");
            string orderChoice = Console.ReadLine();

            if (orderChoice == "1")
            {
                Console.WriteLine("Restaurants list : ");

                var restaurants = restaurantDbManager.GetAllRestaurants();

                foreach (var restaurant in restaurants)
                {
                    Console.WriteLine(restaurant.ToString());
                }

                Console.WriteLine("Choose the restaurant");
                string idRestaurant = Console.ReadLine();


                var dishes = dishDbManager.GetAllDishes(int.Parse(idRestaurant));

                foreach (var dish in dishes)
                {
                    Console.WriteLine(dish.ToString());
                }

                Console.WriteLine("Choose your dish");
                string dishChoice = Console.ReadLine();

                int dishPrice = dishDbManager.GetDishPrice(int.Parse(dishChoice));

                Console.WriteLine("How many times do you want this dish ?");
                string dishQuantity = Console.ReadLine();

                int totalPrice = dishPrice * int.Parse(dishQuantity);

                var newOrder = orderDbManager.AddOrder(new Order {
                    Status = "In procedure", FK_idCustomer = idCustomer
                });

                orderDishDbManager.AddOrder_Dish(new Order_Dish {
                    Quantity = dishQuantity, FK_idDish = int.Parse(dishChoice), FK_idOrder = newOrder.IdOrder
                });

                //Sans plusieurs ordres, ça fonctionne

                /*while (dishChoice != "0")
                 * {
                 *  Console.WriteLine("Would you like something else ? If your order is done, insert [0]");
                 *  dishChoice = Console.ReadLine();
                 *  dishPrice = dishDbManager.GetDishPrice(int.Parse(dishChoice));
                 *
                 *  if (dishChoice != "0")
                 *  {
                 *      Console.WriteLine("How many times do you want this dish ?");
                 *      dishQuantity = Console.ReadLine();
                 *      totalPrice += dishPrice * int.Parse(dishQuantity);
                 *  }
                 *
                 *  //Bug ici à corriger
                 *  orderDishDbManager.AddOrder_Dish(new Order_Dish { Quantity = dishQuantity, FK_idDish = int.Parse(dishChoice), FK_idOrder = newOrder.IdOrder});
                 * }*/

                Console.WriteLine("The total of your command is : CHF " + totalPrice + ".-");

                Console.WriteLine("When do you want your order to be delivered ? Choose the time with the ID");


                var delivery_times = delivery_TimeDbManager.GetAllDelivery_Time();
                foreach (var delivery_time in delivery_times)
                {
                    Console.WriteLine(delivery_time.ToString());
                }

                string deliveryTimeChoice = Console.ReadLine();

                Console.WriteLine("Do you validate this order ? Yes [Y], No [N]");
                string validationChoice = Console.ReadLine();

                if (validationChoice == "Y")
                {
                    Console.WriteLine("Thank you for ordering with Liam & Mathieu Food Delivery !");
                    Console.WriteLine("Your order will be there at " + delivery_TimeDbManager.GetDelivery_Time(int.Parse(deliveryTimeChoice)));


                    int idCityFromRestaurant = restaurantDbManager.GetidCityFromRestaurant(int.Parse(idRestaurant));

                    var deliverymans = deliverymanDbMangager.GetAllDeliveryman(idCityFromRestaurant);

                    foreach (var deliveryman in deliverymans)
                    {
                        //if(deliveryman.FK_idDelivery<5 && deliveryman.)
                    }

                    deliveryDbManager.AddDelivery(new Delivery {
                        FK_idOrder = newOrder.IdOrder, FK_idRestaurant = int.Parse(idRestaurant), FK_idDelivery_Time = int.Parse(deliveryTimeChoice)
                    });
                }

                else
                {
                    Console.WriteLine("You canceled the order. See you soon !");
                }
            }
            else
            {
                Console.WriteLine("Here is the list of your orders : ");

                var orders = orderDbManager.GetAllOrdersForOneCustomer(idCustomer);

                foreach (var order in orders)
                {
                    Console.WriteLine(order.ToString());
                }

                Console.WriteLine("Choose the order you want to delete with the id");
                string orderDelete = Console.ReadLine();
                var    code        = customerDbManager.Code(idCustomer) + orderDelete;
                Console.WriteLine("Here is your cancellation code for the chosen order :" + ' ' + code);
                Console.WriteLine("Insert you cancellation code :");
                string codeInserted = Console.ReadLine();
                while (codeInserted != code)
                {
                    Console.WriteLine("Cancellation code wrong. Try again.");
                    codeInserted = Console.ReadLine();
                }
                Console.WriteLine("Are you sure you want to cancel this order ? Yes [Y], No [N]");
                string choice = Console.ReadLine();
                if (choice == "Y")
                {
                    //Change status order
                    Console.WriteLine("Your order has been successfully cancelled !");
                }
                Console.WriteLine("Your order has not been cancelled");
            }
        }