Exemple #1
0
        public IList <Standard> GetStandards(StandardQuery query)
        {
            var standards = StandardStorage.GetData().Select(x => x.Value);

            if (query.StandardSubjectId.HasValue)
            {
                standards = standards.Where(x => x.StandardSubjectRef == query.StandardSubjectId);
            }
            if (query.GradeLavelId.HasValue)
            {
                standards =
                    standards.Where(
                        x => query.GradeLavelId <= x.LowerGradeLevelRef && query.GradeLavelId >= x.UpperGradeLevelRef);
            }
            if (!query.AllStandards || query.ParentStandardId.HasValue)
            {
                standards = standards.Where(x => x.ParentStandardRef == query.ParentStandardId);
            }

            if (query.ClassId.HasValue)
            {
                var classStandarts = ClassStandardStorage.GetAll(query.ClassId).Select(x => x.StandardRef);
                standards = standards.Where(x => classStandarts.Contains(x.Id));
            }
            //if (query.CourseId.HasValue)
            //{
            //    var classStandarts = Storage.ClasStandardStorage.GetAll(query.CourseId).Select(x => x.StandardRef);
            //    standards = standards.Where(x => classStandarts.Contains(x.Id));
            //}

            return(standards.ToList());
        }
Exemple #2
0
        private void InsertDefaultClassStandards()
        {
            var standardsIds   = StandardStorage.GetData().Keys.ToList();
            var classStandards = ClassStandardStorage.GetAll();

            standardsIds = standardsIds.Where(x => classStandards.All(y => y.StandardRef != x)).ToList();
            var classes           = ServiceLocator.ClassService.GetAll();
            var newClassStandards = new List <ClassStandard>();

            foreach (var c in classes)
            {
                newClassStandards.AddRange(standardsIds.Select(id => new ClassStandard
                {
                    ClassRef    = c.Id,
                    StandardRef = id
                }).ToList());
            }
            ClassStandardStorage.Add(newClassStandards);
        }