예제 #1
0
        public void menuPage_ViewMenuItems()
        {
            Task.Run(() => GetMenuItemsRequest.SendGetMenuItemsRequest());

            int menuItemCount = testMenuList.menuItems.Count();

            Assert.AreEqual(menuItemCount, 12);
        }
예제 #2
0
        public async Task RefreshMenuItemLists()
        {
            var validMenuItemList = await GetMenuItemsRequest.SendGetMenuItemsRequest();

            var menuItemsList = RealmManager.All <MenuItemList>().FirstOrDefault().menuItems;

            uxAppliedItemsList.ItemsSource  = menuItemsList;
            uxRequiredItemsList.ItemsSource = menuItemsList;
        }
예제 #3
0
        public async void RefreshEmployeeList()
        {
            RealmManager.RemoveAll <EmployeeList>();
            RealmManager.RemoveAll <Employee>();
            await GetEmployeeListRequest.SendGetEmployeeListRequest();

            await GetMenuItemsRequest.SendGetMenuItemsRequest();

            uxEmployeeListView.ItemsSource = RealmManager.All <EmployeeList>().FirstOrDefault().employees.ToList();
        }
예제 #4
0
        private async void RefreshMenuItemList()
        {
            RealmManager.RemoveAll <MenuItemList>();
            RealmManager.RemoveAll <MenuItem>();
            var validGetMenuItemsRequest = await GetMenuItemsRequest.SendGetMenuItemsRequest();

            if (validGetMenuItemsRequest)
            {
                uxMenuItemListView.ItemsSource = RealmManager.All <MenuItemList>().FirstOrDefault().menuItems.ToList();
            }
        }
예제 #5
0
        public void CheckOut_MenuItemsRemove()
        {
            Task.Run(() => GetMenuItemsRequest.SendGetMenuItemsRequest());

            OrderList testOrder = new OrderList();

            TabletApp.Models.MenuItem  testItem      = testMenuList.menuItems[0];
            TabletApp.Models.OrderItem testOrderItem = new OrderItem(testItem);

            testOrder.orderItems.Add(testOrderItem);
            testOrder.orderItems.Remove(testOrderItem);

            Assert.IsEmpty(testOrder.orderItems);
        }
예제 #6
0
        public void CheckOut_MenuItemsAdd()
        {
            Task.Run(() => GetMenuItemsRequest.SendGetMenuItemsRequest()).Wait();

            testMenuList = RealmManager.All <MenuList>().FirstOrDefault();

            OrderList testOrder = new OrderList();


            TabletApp.Models.MenuItem  testItem      = testMenuList.menuItems[0];
            TabletApp.Models.OrderItem testOrderItem = new OrderItem(testItem);
            testOrder.orderItems.Add(testOrderItem);

            Assert.AreEqual(testOrder.orderItems[0].name, "Dijktra's Jalenpeno Poppers");
        }
예제 #7
0
        private async Task <List <CompDisplay> > SyncCompData(IList <Comp> comps)
        {
            List <CompDisplay> compDisplays = new List <CompDisplay>();

            if (comps.Count == 0)
            {
                return(compDisplays);
            }
            var validGetMenuItems = await GetMenuItemsRequest.SendGetMenuItemsRequest();

            foreach (Comp comp in comps)
            {
                CompDisplay compDisplay = new CompDisplay();
                MenuItem    menuItem    = RealmManager.Find <MenuItem>(comp.menuItem_id);
                compDisplay.MenuItemName = menuItem.name;
                compDisplay.Price        = menuItem.price;
                compDisplay.Reason       = comp.reason;
                compDisplays.Add(compDisplay);
            }
            return(compDisplays);
        }
예제 #8
0
        private async void UpdateHotItem()
        {
            //initalizing last week date
            DateTime td            = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek); //sets td to the beginning of the week
            DateTime lastWeekStart = new DateTime(td.Year, td.Month, td.Day, 0, 0, 0).AddDays(-7);



            //Checking if hotItem are still up to date
            if (RealmManager.All <HotItem>().FirstOrDefault() != null)
            {
                //getting last time hot items have been updated
                DateTime lastUpdated = DateTime.Parse(RealmManager.All <HotItem>().FirstOrDefault().createdAt);

                if (DateTime.Compare(lastWeekStart, lastUpdated) == 0)
                {
                    //return;
                }
            }

            RealmManager.RemoveAll <OrderList>();
            RealmManager.RemoveAll <MenuItemList>();
            List <MenuItem> somelist = new List <MenuItem>();
            //finding each distinct category and adding it
            await GetOrdersRequest.SendGetOrdersRequest();

            await GetMenuItemsRequest.SendGetMenuItemsRequest();

            //creating a list of every menu item id for each order including duplicates
            List <OrderItem> menuItemIds = new List <OrderItem>();
            //creating a dictionary to keep track of the count of each menuItem
            Dictionary <String, Dictionary <MenuItem, int> > menuItemCounter = new Dictionary <String, Dictionary <MenuItem, int> >();

            foreach (Order o in RealmManager.All <OrderList>().FirstOrDefault().orders)
            {
                //this will ignore all uncompleted orders
                if (o.time_completed == null)
                {
                    continue;
                }


                DateTime orderTime = DateTime.ParseExact(o.time_completed.Replace('T', ' ').TrimEnd('Z'), "yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture);

                //Makes it easier for keying the revenue map by WEEK
                orderTime = orderTime.AddDays(-(int)orderTime.DayOfWeek);
                orderTime = new DateTime(orderTime.Year, orderTime.Month, orderTime.Day, 0, 0, 0);

                //only added menuItems from orders for the current month
                if (DateTime.Compare(lastWeekStart, orderTime) == 0)
                {
                    foreach (OrderItem oi in o.menuItems)
                    {
                        menuItemIds.Add(oi); //add next menuitem id
                    }
                }
            }

            List <MenuItem> tempList = RealmManager.All <MenuItem>().ToList();

            //updating menuItem map to see how often each was ordered
            foreach (OrderItem o in menuItemIds)
            {
                MenuItem tempMenuItem = tempList.Find(x => x._id == o._id);
                if (tempMenuItem == null)
                {
                    continue;
                }
                if (menuItemCounter.ContainsKey(tempMenuItem.category))
                {
                    try
                    {
                        menuItemCounter[tempMenuItem.category][tempMenuItem] = menuItemCounter[tempMenuItem.category][tempMenuItem] + 1;
                    }
                    catch
                    {
                        menuItemCounter[tempMenuItem.category].Add(tempMenuItem, 1);
                    }
                }
                else
                {
                    menuItemCounter[tempMenuItem.category] = new Dictionary <MenuItem, int> {
                        { tempMenuItem, 1 }
                    };
                }
            }
            foreach (string key in menuItemCounter.Keys)
            {
                KeyValuePair <MenuItem, int> topMenuItem;
                //finding the top menuItem for each category
                topMenuItem = menuItemCounter[key].Aggregate((x, y) => x.Value > y.Value ? x : y);
                //grabbing what was the top menuItem in the category from the previous week
                HotItem tempItem = RealmManager.Find <HotItem>(topMenuItem.Key.category);

                //if hotitem is in realm yet
                if (tempItem == null)
                {
                    //creating new hotitem object
                    HotItem tempHotItem = new HotItem();
                    tempHotItem.category  = topMenuItem.Key.category;
                    tempHotItem.createdAt = lastWeekStart.ToString();
                    tempHotItem._id       = topMenuItem.Key._id;

                    //getting menuItem object from list using hotItem
                    MenuItem tempMenuItem = tempList.Find(x => x._id == topMenuItem.Key._id);
                    RealmManager.Write(() => tempMenuItem.isHot = true);

                    //updating database
                    var response = await UpdateHotItemRequest.SendUpdateMenuItemRequest(tempMenuItem);

                    //updaing realm
                    RealmManager.AddOrUpdate <HotItem>(tempHotItem);
                    if (!response)
                    {
                        ContentDialog responseAlert = new ContentDialog
                        {
                            Title           = "Unsuccessful",
                            Content         = "Hot Item has not been updated successfully",
                            CloseButtonText = "Ok"
                        };
                        ContentDialogResult result = await responseAlert.ShowAsync();
                    }
                }
                else
                {
                    //if the hot item is infact new
                    if (tempItem._id != topMenuItem.Key._id)
                    {
                        //finding old hotitem menuItem object
                        MenuItem oldMenuItem = tempList.Find(x => x._id == tempItem._id);
                        RealmManager.Write(() => oldMenuItem.isHot = false);

                        //updating old hotItem in database
                        var Firstresponse = await UpdateHotItemRequest.SendUpdateMenuItemRequest(oldMenuItem);

                        if (!Firstresponse)
                        {
                            ContentDialog responseAlert = new ContentDialog
                            {
                                Title           = "Unsuccessful",
                                Content         = "Original hot item has not been updated successfully",
                                CloseButtonText = "Ok"
                            };
                            ContentDialogResult result = await responseAlert.ShowAsync();
                        }

                        //finding new menuItem object using new hotItem
                        MenuItem newMenuItem = tempList.Find(x => x._id == topMenuItem.Key._id);
                        RealmManager.Write(() => newMenuItem.isHot = true);
                        var Secondresponse = await UpdateHotItemRequest.SendUpdateMenuItemRequest(newMenuItem);

                        //updating hot item in realm to match new hot Item
                        RealmManager.Write(() =>
                        {
                            tempItem._id       = topMenuItem.Key._id;
                            tempItem.createdAt = lastWeekStart.ToString();
                        });

                        if (!Secondresponse)
                        {
                            ContentDialog responseAlert = new ContentDialog
                            {
                                Title           = "Unsuccessful",
                                Content         = "Hot Item has not been updated successfully",
                                CloseButtonText = "Ok"
                            };
                            ContentDialogResult result = await responseAlert.ShowAsync();
                        }
                    }
                }
            }
            ContentDialog responseAlertCheck = new ContentDialog
            {
                Title           = "Successful",
                Content         = "Hot Items have been updated successfully",
                CloseButtonText = "Ok"
            };
            ContentDialogResult resultCheck = await responseAlertCheck.ShowAsync();
        }
예제 #9
0
        private async void KPIComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // this is the selections on the combo box
            string viewSelection = e.AddedItems[0].ToString();

            //excutes if the GET order request returns back okay
            if (await GetOrdersRequest.SendGetOrdersRequest() && await GetMenuItemsRequest.SendGetMenuItemsRequest())
            {
                //creating a dictionary to keep track of the count of each menuItem
                Dictionary <String, int> menuItemCounter = new Dictionary <String, int>();
                foreach (MenuItem m in RealmManager.All <MenuItemList>().FirstOrDefault().menuItems)
                {
                    menuItemCounter.Add(m._id, 0);
                }

                //will keep track of revenue made yearly, monthly and weekly
                Dictionary <DateTime, int> revenueCalendar = new Dictionary <DateTime, int>();

                //creating a list of every menu item id for each order including duplicates
                List <string> menuItemIds = new List <string>();

                //Will store a date and the number of orders
                Dictionary <DateTime, int> orderCount = new Dictionary <DateTime, int>();

                //figuring out which view needs to be populated
                switch (viewSelection)
                {
                //MONTHLY VIEW
                case "Current Weekly View":
                    if (await DisplayWeeklyViewAsync(menuItemCounter, revenueCalendar, menuItemIds, orderCount))
                    {
                        break;
                    }
                    else
                    {
                        //Error handling
                        ContentDialog responseAlert = new ContentDialog
                        {
                            Title           = "Weekly View Error",
                            Content         = "Something went wrong with the selection.",
                            CloseButtonText = "Ok"
                        };
                        ContentDialogResult result = await responseAlert.ShowAsync();

                        break;
                    }


                //WEEKLY VIEW
                case "Current Monthly View":
                    if (await DisplayMonthlyViewAsync(menuItemCounter, revenueCalendar, menuItemIds, orderCount))
                    {
                        break;
                    }
                    else
                    {
                        //Error handling
                        ContentDialog responseAlert = new ContentDialog
                        {
                            Title           = "Monthly View Error",
                            Content         = "Something went wrong with the selection.",
                            CloseButtonText = "Ok"
                        };
                        ContentDialogResult result = await responseAlert.ShowAsync();

                        break;
                    }

                //YEARLY VIEW
                case "Current Yearly View":
                    if (await DisplayYearlyViewAsync(menuItemCounter, revenueCalendar, menuItemIds, orderCount))
                    {
                        break;
                    }
                    else
                    {
                        //Error handling
                        ContentDialog responseAlert = new ContentDialog
                        {
                            Title           = "Yearly View Error",
                            Content         = "Something went wrong with the selection.",
                            CloseButtonText = "Ok"
                        };
                        ContentDialogResult result = await responseAlert.ShowAsync();

                        break;
                    }
                }
            }
            else
            {
                //Error handling
                ContentDialog responseAlert = new ContentDialog
                {
                    Title           = "Combobox Error",
                    Content         = "Something went wrong with the selection.",
                    CloseButtonText = "Ok"
                };
                ContentDialogResult result = await responseAlert.ShowAsync();
            }
        }
예제 #10
0
        async void SetupMenuItems()
        {
            await GetMenuItemsRequest.SendGetMenuItemsRequest();

            await GetIngredientsRequest.SendGetIngredientsRequest();

            IngredientList ingredientList = new IngredientList();

            for (int i = 0; i < RealmManager.All <IngredientList>().First().doc.Count(); i++)
            {
                ingredientList.doc.Add(RealmManager.All <IngredientList>().First().doc[i]);
            }

            for (int i = 0; i < RealmManager.All <MenuList>().First().menuItems.Count(); i++)
            {
                Models.MenuItem currItem = RealmManager.All <MenuList>().First().menuItems[i];

                bool available = true;

                for (int j = 0; j < currItem.ingredients.Count(); j++)
                {
                    IList <Ingredient> ingredients = ingredientList.doc.Where((Ingredient ing) => (ing._id == currItem.ingredients[j]._id)).ToList <Ingredient>();

                    for (int k = 0; k < ingredients.Count(); k++)
                    {
                        if (ingredients[k].quantity == 0)
                        {
                            available = false;
                            break;
                        }
                    }

                    if (!available)
                    {
                        break;
                    }
                }

                if (!available)
                {
                    continue;
                }

                Button newButton = new Button()
                {
                    Text            = currItem.name,
                    Margin          = new Thickness(30, 0, 30, 15),
                    FontSize        = 20,
                    WidthRequest    = 100,
                    FontAttributes  = FontAttributes.Bold,
                    TextColor       = Xamarin.Forms.Color.White,
                    CornerRadius    = 15,
                    BackgroundColor = Xamarin.Forms.Color.FromHex("#24BF87"),
                };

                newButton.Clicked += async(sender, args) => await Navigation.PushAsync(new menuItemPage(currItem));

                if (currItem.category == "Entrees")
                {
                    entreeScroll.Children.Add(newButton);
                }
                else if (currItem.category == "Appetizers")
                {
                    appScroll.Children.Add(newButton);
                }
                else if (currItem.category == "Kids Meals")
                {
                    kidsScroll.Children.Add(newButton);
                }
                else if (currItem.category == "Drinks")
                {
                    drinkScroll.Children.Add(newButton);
                }
                else if (currItem.category == "Sides")
                {
                    sideScroll.Children.Add(newButton);
                }
                else if (currItem.category == "Desserts")
                {
                    dessertScroll.Children.Add(newButton);
                }
                else if (currItem.category == "$5 Meal Deals")
                {
                    fiveMealScroll.Children.Add(newButton);
                }
                else
                {
                    otherScroll.Children.Add(newButton);
                }
            }
        }