/// <summary>
        /// This driver called Command Design Pattern
        /// </summary>
        /// <param name="selectedMealItems"></param>
        /// <param name="totalCost"></param>
        /// <param name="restaurantId"></param>
        /// <param name="orderId"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public string MealOrderByUser(ICollection <FoodMenuModel> selectedMealItems, string restaurantId, Customer customer)
        {
            //Food
            Meal meal = new Meal();

            meal.AddFoodItem(selectedMealItems.ToList());

            Food      food      = new Food();
            OrderFood orderFood = new OrderFood(food);

            ;
            //customer detals
            orderFood.User             = new Customer();
            orderFood.User.UserName    = customer.UserName;
            orderFood.User.Address     = customer.Address;
            orderFood.User.PhoneNumber = customer.PhoneNumber;
            var cust = orderFood.AddCustomerIfNotExists(orderFood.User);

            orderFood.User.CustomerId = cust.CustomerId;

            //payment
            orderFood.User.Amount  = meal.GetCost();
            orderFood.RestaurantId = restaurantId;
            ;
            // Place Order
            orderFood.Execute();
            var menuList = meal.FoodItems;

            return(!orderFood.AddOrderDetails(orderFood.OrderId, menuList)
                ? "An error occured while placing the order"
                : orderFood.OrderId);
        }
Exemple #2
0
 private void UpdateOrder(ICollection <FoodMenuModel> lists)
 {
     order.AddOrderDetails(OrderId, lists.ToList());
 }