Esempio n. 1
0
        private void UpdateWeightCategories()
        {
            if (Class == null || Class.IsNoClassClass)
            {
                return;
            }

            WeightCategories = GetWeightCategories(Class);

            if (SelectedWeightCategory == null || !WeightCategories.Contains(SelectedWeightCategory))
            {
                ViewItemWeightCategory selectedWeightCategory = null;
                if (EditParams != null)
                {
                    selectedWeightCategory = WeightCategories.FirstOrDefault(i => i.Identifier == EditParams.Item.WeightCategoryIdentifier);
                }
                else
                {
                    selectedWeightCategory = WeightCategories.FirstOrDefault(i => i.Identifier == NavigationManager.SelectedWeightCategoryIdentifier);
                }

                if (selectedWeightCategory == null)
                {
                    SelectedWeightCategory = ViewItemWeightCategory.UNASSIGNED;
                }
                else
                {
                    SelectedWeightCategory = selectedWeightCategory;
                }
            }
        }
        private void HandleWeightCategoryForHomeworkExam(BaseViewItemHomeworkExam item)
        {
            if (item.WeightCategoryIdentifier == PowerPlannerSending.BaseHomeworkExam.WEIGHT_CATEGORY_UNASSIGNED)
            {
                item.WeightCategory = ViewItemWeightCategory.UNASSIGNED;
            }
            else if (item.WeightCategoryIdentifier == PowerPlannerSending.BaseHomeworkExam.WEIGHT_CATEGORY_EXCLUDED)
            {
                item.WeightCategory = ViewItemWeightCategory.EXCLUDED;
            }
            else
            {
                if (WeightCategories == null)
                {
                    // WeightCategories should only be null in the scenario where the view group was loaded disregarding
                    // the weight categories (like from the live tile task)
                    item.WeightCategory = null;
                    return;
                }

                var weight = WeightCategories.FirstOrDefault(i => i.Identifier == item.WeightCategoryIdentifier);
                if (weight != null)
                {
                    item.WeightCategory = weight;
                }
                else
                {
                    item.WeightCategory = ViewItemWeightCategory.UNASSIGNED;
                }
            }
        }