/// <summary> /// Updates <see cref="Retailers"/> after a retailer is added, edited, or deleted from the database /// </summary> /// <remarks> /// LoadRetailers() can't be used in place of UpdateRetailers() because the list in the settings UI is bound to the /// observable collection Retailers <see cref="Retailers"/>. LoadRetailers() would break the binding and not update /// in real time if the user were to make a change /// </remarks> public void UpdateRetailers() { Handlers.Database db = new Handlers.Database(); var retailerList = db.LoadAllRetailers(); Retailers.Clear(); foreach (var retailer in retailerList) { Retailers.Add(retailer); } sortedByName = false; SortRetailersByName(); sortedByName = false; }
/// <summary> /// Sorts <see cref="Retailers"/> by retailer cooler percentage in ascending or descending order (depending on UI interaction) /// </summary> public void SortRetailersByCooler() { if (sortedByCooler == false) { ObservableCollection <Retailer> tmp = new ObservableCollection <Retailer>(Retailers.OrderBy(Retailer => Retailer.CoolerPercentage)); Retailers.Clear(); foreach (Retailer i in tmp) { Retailers.Add(i); } sortedByCooler = true; } else { ObservableCollection <Retailer> tmp = new ObservableCollection <Retailer>(Retailers.OrderByDescending(Retailer => Retailer.CoolerPercentage)); Retailers.Clear(); foreach (Retailer i in tmp) { Retailers.Add(i); } sortedByCooler = false; } }
/// <summary> /// Sorts <see cref="Retailers"/> by retailer online abbreviation in ascending or descending order (depending on UI interaction) /// </summary> public void SortRetailersByAbbreviation() { if (sortedByAbbrev == false) { ObservableCollection <Retailer> tmp = new ObservableCollection <Retailer>(Retailers.OrderBy(Retailer => Retailer.OnlineAbbrev)); Retailers.Clear(); foreach (Retailer i in tmp) { Retailers.Add(i); } sortedByAbbrev = true; } else { ObservableCollection <Retailer> tmp = new ObservableCollection <Retailer>(Retailers.OrderByDescending(Retailer => Retailer.OnlineAbbrev)); Retailers.Clear(); foreach (Retailer i in tmp) { Retailers.Add(i); } sortedByAbbrev = false; } }