Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 public UpdateFood(Food food, OrderFood order)
 {
     this.food  = food;
     this.order = order;
 }