public MenuItemDetailVM(Page page, string restoName, MenuDAO menu)
     : base(page)
 {
     Title = restoName;
     StoreName = restoName;
     this.Menu = menu;
 }
        public void AddOrderItem(MenuDAO menu)
        {
            var odrepo = RepositoryManager.OrderDetailRepo();
            var odList = odrepo.GetItems().ToList();
            var existingOrder = odrepo.SearchFor(c => c.MenuID == menu.MenuID);
            if (existingOrder.Any())
            {
                var oditem = odrepo.GetItem(existingOrder.FirstOrDefault().ID);
                oditem.Quantity = menu.QuantityOrdered;
                oditem.TotalAmount = menu.Price * menu.QuantityOrdered;
                oditem.TaxAmount = menu.Price * menu.QuantityOrdered * 0.10m;
                if (oditem.Quantity < 1)
                    odrepo.DeleteItem(oditem);
                else
                    odrepo.SaveItem(oditem);
            }
            else if (menu.QuantityOrdered > 0)
            {
                var item = new OrderDetailDAO()
                {
                    MenuID = menu.MenuID,
                    Price = menu.Price,
                    Quantity = menu.QuantityOrdered,
                    RestaurantId = 1,
                    TotalAmount = menu.Price * menu.QuantityOrdered,
                    TaxAmount = menu.Price * menu.QuantityOrdered * 0.10m,
                };
                odrepo.SaveItem(item);
            }

            var checklist = odrepo.GetItems().ToList();
        }
        public async void MenuCollectionUpdate(MenuDAO menu)
        {
            var showAlert = false;
            var menulist = new List<MenuDAO>();
            try
            {
                AddOrderItem(menu); //Add order to menu
                menulist = GetMenuItems(); // Get new menu list;

                var dicMenuCollection = menulist
                .GroupBy(c => c.MenuCategory)
                .Select(c => new DisplayMenu()
                {
                    MenuCategory = c.Key,
                    MenuList = c.Select(m => new MenuDAO()
                    {
                        ID = m.ID,
                        MenuID = m.MenuID,
                        Name = m.Name,
                        Description = m.Description,
                        MenuCategory = m.MenuCategory,
                        MenuType = m.MenuType,
                        Price = m.Price,
                        ThumbUrl = m.ThumbUrl

                    }).ToList()

                }).ToList();

                MenuCollection = new ObservableCollection<DisplayMenu>(dicMenuCollection);
                OnPropertyChanged("MenuCollection");
            }
            catch (Exception ex)
            {
                showAlert = true;
            }

            if (showAlert)
                await page.DisplayAlert("Uh Oh :(", "Unable to update menu order.", "OK");
            
        }
 public MenuItemDetailPage(string storeName, MenuDAO menu)
 {
     InitializeComponent();
     BindingContext = viewModel = new MenuItemDetailVM(this, storeName, menu);
 }