internal void Add(ViewItemWeightCategory viewItemWeightCategory)
        {
            viewItemWeightCategory.Class = this;

            if (WeightCategories != null)
            {
                WeightCategories.InsertSorted(viewItemWeightCategory);
            }

            _needsRecalc = true;
        }
        private void SetChecked(DayOfWeek dayOfWeek, bool isChecked)
        {
            if (isChecked)
            {
                if (!DayOfWeeks.Contains(dayOfWeek))
                {
                    DayOfWeeks.InsertSorted(dayOfWeek);
                }
            }

            else
            {
                DayOfWeeks.Remove(dayOfWeek);
            }
        }
Esempio n. 3
0
        public async void LoadGrades()
        {
            try
            {
                if (_hasGradesBeenRequested)
                {
                    return;
                }

                _hasGradesBeenRequested = true;

                await Task.Run(async delegate
                {
                    try
                    {
                        var dataStore = await GetDataStore();

                        DataItemGrade[] dataGrades;
                        DataItemMegaItem[] dataItems;

                        using (await Locks.LockDataForReadAsync())
                        {
                            Guid[] weightIds = this.Class.WeightCategories.Select(i => i.Identifier).ToArray();

                            dataGrades = dataStore.TableGrades.Where(i => weightIds.Contains(i.UpperIdentifier)).ToArray();

                            dataItems = dataStore.TableMegaItems.Where(i =>
                                                                       (i.MegaItemType == PowerPlannerSending.MegaItemType.Exam || i.MegaItemType == PowerPlannerSending.MegaItemType.Homework) &&
                                                                       i.UpperIdentifier == _classId &&
                                                                       i.WeightCategoryIdentifier != PowerPlannerSending.BaseHomeworkExam.WEIGHT_CATEGORY_EXCLUDED)
                                        .ToArray();

                            var unassignedItems = new MyObservableList <BaseViewItemHomeworkExam>();
                            unassignedItems.InsertSorted(dataItems
                                                         .Where(i => IsUnassignedChild(i))
                                                         .Select(i =>
                                                                 i.MegaItemType == PowerPlannerSending.MegaItemType.Homework ?
                                                                 new ViewItemHomework(i)
                            {
                                Class = this.Class, WeightCategory = ViewItemWeightCategory.UNASSIGNED
                            } as BaseViewItemHomeworkExam
                                        : new ViewItemExam(i)
                            {
                                Class = this.Class, WeightCategory = ViewItemWeightCategory.UNASSIGNED
                            }));

                            PortableDispatcher.GetCurrentDispatcher().Run(delegate
                            {
                                try
                                {
                                    foreach (var weight in this.Class.WeightCategories)
                                    {
                                        weight.AddGradesHelper(ViewItemWeightCategory.CreateGradeHelper);

                                        weight.FilterAndAddChildren <BaseDataItemHomeworkExamGrade>(dataGrades);
                                        weight.FilterAndAddChildren <BaseDataItemHomeworkExamGrade>(dataItems);
                                    }

                                    Class.CalculateEverything();

                                    UnassignedItems    = unassignedItems;
                                    HasUnassignedItems = unassignedItems.Count > 0;

                                    _loadGradesTaskSource.SetResult(true);
                                    IsGradesLoaded = true;
                                }
                                catch (Exception ex)
                                {
                                    TelemetryExtension.Current?.TrackException(ex);
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        TelemetryExtension.Current?.TrackException(ex);
                    }
                });
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
 internal void Add(ViewItemYear year)
 {
     Years.InsertSorted(year);
 }