Esempio n. 1
0
        /// <summary>
        ///     Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService, IWindowService windowService)
        {
            _dataService = dataService;
            _windowService = windowService;
            Headers = new List<Header>();
            Meals = new List<Meal>();
            OrderItems = new ObservableCollection<OrderItem>();
            if (IsInDesignMode)
            {
                var orderItem = new OrderItem
                {
                    Description = "Meal Description",
                    Price = 10.95M,
                    Notes = "These are meal notes"
                };
                OrderItems.Add(orderItem);

                var header = new Header {Title = "Starters"};
                Headers.Add(header);

                var meal = new Meal
                {
                    Price = 5m,
                    ChickenPrice = 5m,
                    KingPrawnPrice = 5m,
                    LambPrice = 5m,
                    PrawnPrice = 5m,
                    VegetablePrice = 5m,
                    Title = "This is a meal"
                };
                Meals.Add(meal);
                OrderNumber = "A0001";
                Address = "David McCallum" + Environment.NewLine + "10 Bingham Broadway" + Environment.NewLine +
                          "EH15 3JL" + Environment.NewLine + "07757 438 032";
            }
            OrderNumber = "A0001";
            Address = "David McCallum" + Environment.NewLine + "10 Bingham Broadway" + Environment.NewLine +
                      "EH15 3JL" + Environment.NewLine + "07757 438 032";
            OrderItems.CollectionChanged += UpdateTotals;
        }
Esempio n. 2
0
 private void MealAdded(object sender, MealAddedEventArgs e)
 {
     var meal = sender as Meal;
     if (meal == null) return;
     var id = OrderItems.Count == 0 ? 1 : OrderItems.Max(order => order.Id) + 1;
     var item = new OrderItem();
     item.AddMeal(id, meal, e.MealType);
     item.OrderDeleted += DeleteOrderItem;
     OrderItems.Add(item);
     OnOrderItemAdded(new OrderItemAddedEventArgs {OrderItemAdded = item});
 }