public CharacterListsViewModel(CharacterListProvider provider)
 {
     customLists  = new ObservableList <Item>(provider.ReloadCustomLists().Select(x => new Item(x)));
     DefaultLists = provider.ReloadDefaultLists().Select(x => new Item(x.Value, true)
     {
         Name = this["CharacterLists_" + x.Key]
     }).ToList();
     AllLists    = new ConcatenatingObservableList <Item>(DefaultLists, customLists);
     SaveCommand = new MvxCommand(() => {
         provider.DefaultLists = DefaultLists.ToDictionary(x => x.List.Name, x => MapList(x, new CharacterList {
             Name = x.List.Name
         }));
         provider.SaveCustomLists(customLists.ToList().Select(x => {
             var oldList = x.List as CustomCharacterList;
             var list    = MapList(x, new CustomCharacterList(oldList?.Id ?? Guid.NewGuid())
             {
                 Name = x.Name
             });
             if (oldList != null)
             {
                 list.Characters = oldList.Characters;
             }
             return(list);
         }).ToList());
     });
     AddCommand = new MvxCommand(() => customLists.Add(new Item {
         Name = "", SortOrder = 10, TextColor = new MvxColor(0), UnderlineColor = new MvxColor(0)
     }));
 }
Exemple #2
0
        private HopsCollection CreateNewHopsCollection(string email, IMongoCollection <HopsCollection> collection)
        {
            var col = new HopsCollection
            {
                UserEmail = email,
                Hops      = DefaultLists.GetDefaultHopsCollection().ToList()
            };

            collection.InsertOne(col);
            return(col);
        }
Exemple #3
0
        private YeastCollection CreateNewYeastCollection(string email, IMongoCollection <YeastCollection> collection)
        {
            var col = new YeastCollection
            {
                UserEmail = email,
                Yeast     = DefaultLists.GetDefaultYeast().ToList()
            };

            collection.InsertOne(col);
            return(col);
        }
Exemple #4
0
        private FermentableCollection CreateNewFermentableCollection(string email, IMongoCollection <FermentableCollection> collection)
        {
            var col = new FermentableCollection
            {
                UserEmail    = email,
                Fermentables = DefaultLists.GetDefaultFermentableCollection().ToList()
            };

            collection.InsertOne(col);
            return(col);
        }