Exemplo n.º 1
0
        void ObjectsReposidory_ExercisesLoaded(object sender, EventArgs e)
        {
            if (!ApplicationState.Current.Cache.Supplements.IsLoaded)
            {
                onSupplementsLoaded();
                BAMessageBox.ShowError(ApplicationStrings.SupplementChooserViewModel_ErrRetrieveSupplements);
                return;
            }
            if (GroupedSupplements == null)
            {
                GroupedSupplements = new ObservableCollection <InGroup <SuplementDTO> >();
            }
            else
            {
                GroupedSupplements.Clear();
            }

            Dictionary <string, InGroup <SuplementDTO> > groups = new Dictionary <string, InGroup <SuplementDTO> >();

            foreach (char c in Groups)
            {
                var group = new InGroup <SuplementDTO>(c.ToString());
                GroupedSupplements.Add(group);
                groups[c.ToString()] = group;
            }

            foreach (var supplement in ApplicationState.Current.Cache.Supplements.Items.Values.OrderBy(x => x.Name))
            {
                groups[GetFirstNameKey(supplement)].Add(supplement);
            }


            onSupplementsLoaded();
        }
        public CountrySelectorViewModel()
        {
            GroupedCountries = new ObservableCollection <InGroup <Country> >();

            var groups = new Dictionary <string, InGroup <Country> >();

            foreach (char c in Groups)
            {
                var group = new InGroup <Country>(c.ToString());
                GroupedCountries.Add(group);
                groups[c.ToString()] = group;
            }



            foreach (var country in Country.GetCountries())
            {
                groups[GetFirstNameKey(country)].Add(country);
            }
        }