public ObservableCollection<OnTheSpot.Models.Category> GetCats(out string error) { ObservableCollection<OnTheSpot.Models.Category> modelCats = null; error = string.Empty; try { List<Category> dbCats = db.Categories.ToList(); modelCats = new ObservableCollection<OnTheSpot.Models.Category>(); foreach (Category cat in dbCats) { OnTheSpot.Models.Category model = new OnTheSpot.Models.Category() { ID = cat.ID, Description = cat.Description, Name = cat.Name }; modelCats.Add(model); } } catch (Exception e) { error = "Critical Error: Could not open Categories DataBase"; } return modelCats; }
public ObservableCollection <OnTheSpot.Models.Category> GetCats(out string error) { ObservableCollection <OnTheSpot.Models.Category> modelCats = null; error = string.Empty; try { List <Category> dbCats = db.Categories.ToList(); modelCats = new ObservableCollection <OnTheSpot.Models.Category>(); foreach (Category cat in dbCats) { OnTheSpot.Models.Category model = new OnTheSpot.Models.Category() { ID = cat.ID, Description = cat.Description, Name = cat.Name }; modelCats.Add(model); } } catch (Exception e) { error = "Critical Error: Could not open Categories DataBase"; } return(modelCats); }
public ObservableCollection <OnTheSpot.Models.Category> GetBCSCats(out string error) { ObservableCollection <OnTheSpot.Models.Category> modelCats = null; //categorys were added for the QCS so need to remove for BCS List <string> QCSCats = new List <string>() { "Shirts", "bottoms", "tops", "Household" }; error = string.Empty; try { List <Category> dbCats = db.Categories.ToList(); modelCats = new ObservableCollection <OnTheSpot.Models.Category>(); foreach (Category cat in dbCats) { if (QCSCats.Contains(cat.Name)) { continue; } OnTheSpot.Models.Category model = new OnTheSpot.Models.Category() { ID = cat.ID, Description = cat.Description, Name = cat.Name }; modelCats.Add(model); } } catch (Exception e) { if (e.InnerException == null) { error = e.Message; } else { error = e.InnerException.Message; } } return(modelCats); }