Пример #1
0
        public void CreateDbIfNotxitsAndInit()
        {
            if (!db.DatabaseExists())
            {
                AllActivityItems      = new ObservableCollection <Activity>();
                AllFolderItems        = new ObservableCollection <Folder>();
                AllScheduleItems      = new ObservableCollection <Schedule>();
                AllGroupItems         = new ObservableCollection <Group>();
                AllHistoryItems       = new ObservableCollection <History>();
                AllActivityGroupItems = new ObservableCollection <ActivityGroup>();

                db.CreateDatabase();
                CreateActivity("Aktivita 1");
                CreateActivity("Aktivita 2");
                CreateActivity("Aktivita 3");
                CreateActivity("Aktivita 4");
                CreateActivity("Aktivita 5");
                CreateActivity("Aktivita 6");
                CreateActivity("Aktivita 7");
                CreateActivity("Aktivita 8");
                CreateActivity("Aktivita 9");

                CreateSchedule(AllActivityItems[0]);
                CreateSchedule(AllActivityItems[1]);
                CreateSchedule(AllActivityItems[2]);
            }
            else
            {
                AllActivityItems      = new ObservableCollection <Activity>(db.Activities);
                AllFolderItems        = new ObservableCollection <Folder>(db.Folders);
                AllScheduleItems      = new ObservableCollection <Schedule>(db.Schedules.OrderBy(x => x.Order));
                AllGroupItems         = new ObservableCollection <Group>(db.Group);
                AllHistoryItems       = new ObservableCollection <History>(db.History);
                AllActivityGroupItems = new ObservableCollection <ActivityGroup>(db.ActivityGroup);
            }

            //if (!db.DatabaseExists()) { db.CreateDatabase(); }
            //AllActivityItems = new ObservableCollection<Activity>(db.Activities);
            //AllFolderItems = new ObservableCollection<Folder>(db.Folders);
            //AllScheduleItems = new ObservableCollection<Schedule>(db.Schedules.OrderBy(x => x.Order));
            //AllGroupItems = new ObservableCollection<Group>(db.Group);
            //AllHistoryItems = new ObservableCollection<History>(db.History);
            //AllActivityGroupItems = new ObservableCollection<ActivityGroup>(db.ActivityGroup);
        }