예제 #1
0
        public sealed override void RefreshData()
        {
            // get classes
            var currentSchool    = GetCurrentSchool();
            var classes          = ClassesRealm.GetAll(x => x.School == currentSchool).ToList();
            var classesContainer = new List <ViewModels.Controls.PrettyListViewItems.ClassDate>();

            var currentDate = SelectedDate;

            for (var i = 0; i < 7; i++)
            {
                // increase current date by one day
                currentDate = currentDate.AddDays(1);

                // loop through all classes
                foreach (var classModel in classes)
                {
                    // if class falls on the current date, add it to the list with the current date
                    if (classModel.Day == currentDate.DayOfWeek.ToString())
                    {
                        var classDate            = currentDate.UtcDateTime.Date;
                        var canceledClassesRealm = new Domain.Services.Realms.CanceledClasses();
                        var canceledClass        = canceledClassesRealm.GetRealmResults()
                                                   .Where(x => x.Class == classModel)
                                                   .FirstOrDefault(x => x.Date == classDate);
                        var canceledRecordExists = canceledClass != null;
                        var isCanceled           = canceledRecordExists && canceledClass.IsCanceled;
                        classesContainer.Add(new ViewModels.Controls.PrettyListViewItems.ClassDate(classModel, currentDate, isCanceled));
                    }
                }
            }

            ClassesList.Clear();
            ClassesList.AddRange(classesContainer);
        }
예제 #2
0
        public sealed override void RefreshData()
        {
            var currentSchool    = GetCurrentSchool();
            var classes          = ClassesRealm.GetAll(x => x.School == currentSchool).ToList();
            var classesContainer = new List <ViewModels.Controls.PrettyListViewItems.Class>();

            foreach (var classModel in classes)
            {
                classesContainer.Add(new ViewModels.Controls.PrettyListViewItems.Class(classModel));
            }
            ClassesList.Clear();
            ClassesList.AddRange(classesContainer);
        }