/// <summary> /// Sets the category list of Category objects. /// </summary> protected void SetCategoryList() { // Iterate through the list of Business to get each Category foreach (var b in BusinessList) { // A Business will have n Categories (a given Category may have a unique list of Subcategories) foreach (var c in b.CategoryList) { Predicate <Category> catFinder = (Category catToFind) => { return(catToFind.Name == c.Name); }; Category oldCat = CategoryList.Find(catFinder); // Insert new Category or update the SubcategoryList of a Category already represented in CategoryList if (oldCat == null) { CategoryList.Add(c); } else { foreach (var sc in c.SubcategoryList) { oldCat.SubcategoryList.Add(sc); } CategoryList.Insert(CategoryList.FindIndex(catFinder), oldCat); } } } }
public async override void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); CategoryList = await App.DbHelper.GetAllCategory(); string categoryId = parameters["categoryId"] as String; SelectedCategory = CategoryList.Find(e => e.Id.Equals(categoryId)); IsVisibleItemList = true; }
protected string MapCategoryIDToName(int ID) { if (this.CategoryList != null) { CategoryModel category = CategoryList.Find(currentCategory => currentCategory.ID == ID); if (category != null) { return(category.NAME); } } return("Categoria Nao Cadastrada!"); }
public void RemoveCategory(int categoryId) { CategoryList.Remove(CategoryList.Find(x => x.Id == categoryId)); }