/// <summary> /// Fetches ProductTabs. /// </summary> public void FetchView() { var first = -1; var foundFirst = false; //var product = new ProductController(new ProductDao(new DalFacade())); foreach (var tab in _salesController.ProductTabs.OrderBy(p => p.Priority)) { TabHead.Add(new TabHeader(tab.Id, tab.Name, ChangeTab, tab.Color)); if (!foundFirst) { first = tab.Id; foundFirst = true; } var tabItem = new List <TabItem>(); var i = 0; var j = 0; foreach (var productType in tab.ProductTypes) { foreach (var productGroup in productType.ProductGroups) { foreach (var product in productGroup.Products) { tabItem.Add(new TabItem(i, j++, productType, AddProduct, product)); if (j >= 5) { i++; j = 0; } } } } TabDictionary.Add(tab.Id, tabItem); } if (first != -1) { ChangeTabCommand(first); } }
/// <summary> /// The logic for ChangeTab. /// </summary> /// <param name="buttonid">The id for the dictionary.</param> private void ChangeTabCommand(int buttonid) { TabItems.Clear(); TabDictionary[buttonid].ForEach(n => TabItems.Add(n)); BackGroundColour = TabHead.First(th => th.Id == buttonid).Colour; }