Beispiel #1
0
        public MenuViewModel()
        {
            Headers = new List<Header>();
            if (IsInDesignMode)
            {
                var header = new Header {Title = "Header"};
                var meal = new Meal {Title = "Meal"};
                header.Meals.Add(meal);
                Headers.Add(header);
                Meals = new List<Meal>(header.Meals);
                Header = header;
            }
            else
            {
                using (var entities = new HillStationEntities())
                {
                    foreach (var header in entities.Headers.Include(h => h.Meals).OrderBy(h => h.DisplayOrder).ToList())
                    {
                        Headers.Add(new Header(header));
                    }
                }
            }

            Cancel = new RelayCommand(CancelUpdate);
            SaveData = new RelayCommand(Save);
            Decrement = new RelayCommand<string>(p => AdjustPrice(p, -0.05m));
            Increment = new RelayCommand<string>(p => AdjustPrice(p, 0.05m));
        }
Beispiel #2
0
 public Header(Header header)
     : this()
 {
     Id = header.Id;
     Title = header.Title;
     DisplayOrder = header.DisplayOrder;
     foreach (var meal in header.Meals.OrderBy(m => m.DisplayOrder))
     {
         // ReSharper disable once VirtualMemberCallInContructor
         Meals.Add(new Meal(meal));
     }
 }
Beispiel #3
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;
        }