/// <summary> /// Fill the list of categories /// </summary> private void FillCategories() { try { var cred = CredentialManager.GetCredentials(App.CredDb); if (cred == null || cred.UserName.Length < 1) { return; } using var db = new LiteDatabase($"{App.GetDbStringWithoutPass}'{cred.Password}'"); var dbUserCategories = db.GetCollection <UserDataCategories>(DbUserData.UserData_Categories.ToString()); var categoriesExceptAll = dbUserCategories.Query().Where(x => x.CategoryName != "All").Select(x => x.CategoryName).ToList(); var parent = (ModifyGameHostViewModel)Parent; AddCategoryMessage = $"{App.ResMan.GetString("AddCategoryTo")} {parent.GameTitle}"; RemoveCategoryMessage = $"{App.ResMan.GetString("RemoveCategoryFrom")} {parent.GameTitle}"; AddCategoriesCollection.Clear(); RemoveCategoriesCollection.Clear(); DeleteCategoriesCollection.Clear(); if (SelectedGame.Categories == null) { return; } FillAddCategory(categoriesExceptAll); FillRemoveCategory(categoriesExceptAll); FillDeleteCategory(categoriesExceptAll); DeleteCategoryIndex = 0; } catch (Exception e) { App.Logger.Warning(e, "Failed to fill list of categories"); SentrySdk.CaptureException(e); } }
/// <summary> /// Fill the list of AddCategory /// </summary> /// <param name="exceptAllList"></param> private void FillAddCategory(List <string> exceptAllList) { if (exceptAllList.Count > 0 && SelectedGame.Categories.Count > 0) { var validAdd = exceptAllList.Except(SelectedGame.Categories).ToList(); validAdd.Remove("All"); if (validAdd.Count > 0) { AddCategoriesCollection.AddRange(validAdd); IsAddCategoriesEnabled = true; SelectedAddIndex = 0; } else { IsAddCategoriesEnabled = false; } } else { AddCategoriesCollection.Clear(); IsAddCategoriesEnabled = false; SelectedAddValue = string.Empty; } }