Пример #1
0
        public void GetSubjectsTest()
        {
            var list = subjectManager.GetSubjects();

            Assert.IsNotNull(list, "Subjects list is null");

            foreach (var item in list)
            {
                Assert.IsInstanceOfType(item, typeof(SubjectDTO), "Object type is wrong!");
                Assert.IsInstanceOfType(item.Id, typeof(int), "Id is not int");
                Assert.IsInstanceOfType(item.Name, typeof(string), "Subject name is not string");
            }
        }
Пример #2
0
        public double GetTotalAverage()
        {
            double all_averages       = 0;
            int    number_of_subjects = 0;
            double total_average;

            foreach (Subject subject in SubjectManager.GetSubjects())
            {
                all_averages += (double)subject.average;
                if (subject.average != 0)
                {
                    number_of_subjects += 1;
                }
            }

            if (number_of_subjects != 0)
            {
                total_average = (all_averages / number_of_subjects);
            }
            else
            {
                total_average = 0;
            }


            return(total_average);
        }
Пример #3
0
        public List <Subject> GetBestSubject()
        {
            List <Subject> best_subjects = new List <Subject> {
            };
            List <Subject> all_subjects  = SubjectManager.GetSubjects();

            all_subjects.RemoveAll(x => x.average == 0);
            all_subjects.Sort((x, y) => x.average.CompareTo(y.average));

            decimal last_average = 6;

            foreach (Subject subject in all_subjects)
            {
                if (subject.average < last_average)
                {
                    best_subjects.Clear();
                    best_subjects.Add(subject);
                }
                else if (subject.average == last_average)
                {
                    best_subjects.Add(subject);
                }
                last_average = subject.average;
            }

            return(best_subjects);
        }
        public ActionResult Subjects_Select(GridCommand command, long entityId, long instanceId)
        {
            var subjectManager          = new SubjectManager();
            var entityPermissionManager = new EntityPermissionManager();

            try
            {
                var subjectsDb = new List <Subject>();
                var count      = 0;
                if (command != null)// filter subjects based on grid filter settings
                {
                    FilterExpression  filter  = TelerikGridHelper.Convert(command.FilterDescriptors.ToList());
                    OrderByExpression orderBy = TelerikGridHelper.Convert(command.SortDescriptors.ToList());

                    subjectsDb = subjectManager.GetSubjects(filter, orderBy, command.Page, command.PageSize, out count);
                }
                else
                {
                    subjectsDb = subjectManager.Subjects.ToList();
                    count      = subjectsDb.Count();
                }

                var subjects = new List <EntityPermissionGridRowModel>();
                //using (PartyManager partyManager = new PartyManager())

                //foreach (var subject in subjectsDb)
                //{
                //    var rights = entityPermissionManager.GetRights(subject.Id, entityId, instanceId);
                //    var effectiveRights = entityPermissionManager.GetEffectiveRights(subject.Id, entityId, instanceId);

                //    subjects.Add(EntityPermissionGridRowModel.Convert(subject, rights, effectiveRights));
                //}

                var rightsDic          = entityPermissionManager.GetRights(subjectsDb, entityId, instanceId);
                var effectiveRightsDic = entityPermissionManager.GetEffectiveRights(subjectsDb, entityId, instanceId);

                foreach (var item in rightsDic)
                {
                    var subject         = subjectsDb.Where(s => s.Id.Equals(item.Key)).FirstOrDefault();
                    var rights          = item.Value;
                    var effectiveRights = effectiveRightsDic[item.Key];

                    subjects.Add(EntityPermissionGridRowModel.Convert(subject, rights, effectiveRights));
                }

                return(View(new GridModel <EntityPermissionGridRowModel> {
                    Data = subjects, Total = count
                }));
            }
            finally
            {
                subjectManager.Dispose();
                entityPermissionManager.Dispose();
            }
        }
Пример #5
0
 private void btn_AddGrade_Grades_Click(object sender, RoutedEventArgs e)
 {
     if (SubjectManager.GetSubjects().Count == 0)
     {
         no_subjects_created();
     }
     else
     {
         Frame.Navigate(typeof(AddGrade));
     }
 }
Пример #6
0
        public void fill_data()
        {
            foreach (LessonTime lesson_time in MyData.my_lessontimes_list)
            {
                cmb_LessonTime_AddLesson.Items.Add(lesson_time);
            }

            foreach (Subject subject in SubjectManager.GetSubjects())
            {
                cmb_Subject_AddLesson.Items.Add(subject);
            }
        }
Пример #7
0
        public ActionResult Subjects_Select(GridCommand command, long featureId)
        {
            FeaturePermissionManager featurePermissionManager = null;
            SubjectManager           subjectManager           = null;
            FeatureManager           featureManager           = null;

            try
            {
                featurePermissionManager = new FeaturePermissionManager();
                subjectManager           = new SubjectManager();
                featureManager           = new FeatureManager();

                var feature = featureManager.FindById(featureId);

                var featurePermissions = new List <FeaturePermissionGridRowModel>();

                if (feature == null)
                {
                    return(View(new GridModel <FeaturePermissionGridRowModel> {
                        Data = featurePermissions
                    }));
                }

                var subjects = new List <Subject>();
                int count    = subjectManager.Subjects.Count();
                ViewData["subjectsGridTotal"] = count;
                if (command != null)// filter subjects based on grid filter settings
                {
                    FilterExpression  filter  = TelerikGridHelper.Convert(command.FilterDescriptors.ToList());
                    OrderByExpression orderBy = TelerikGridHelper.Convert(command.SortDescriptors.ToList());

                    subjects = subjectManager.GetSubjects(filter, orderBy, command.Page, command.PageSize, out count);
                }
                else
                {
                    subjects = subjectManager.Subjects.ToList();
                }


                //foreach (var subject in subjects)
                //{
                //    var rightType = featurePermissionManager.GetPermissionType(subject.Id, feature.Id);
                //    var hasAccess = featurePermissionManager.HasAccess(subject.Id, feature.Id);

                //    featurePermissions.Add(FeaturePermissionGridRowModel.Convert(subject, featureId, rightType, hasAccess));
                //}

                var subjectIds        = subjects.Select(s => s.Id);
                var userPermissionDic = featurePermissionManager.GetPermissionType(subjectIds, feature.Id);
                var userHasAccessDic  = featurePermissionManager.HasAccess(subjects, feature.Id);

                foreach (var item in userPermissionDic)
                {
                    var subject   = subjects.Where(s => s.Id.Equals(item.Key)).FirstOrDefault();
                    var rightType = item.Value;
                    var hasAccess = userHasAccessDic[item.Key];

                    featurePermissions.Add(FeaturePermissionGridRowModel.Convert(subject, featureId, rightType, hasAccess));
                }


                return(View(new GridModel <FeaturePermissionGridRowModel> {
                    Data = featurePermissions, Total = count
                }));
            }
            finally
            {
                featureManager?.Dispose();
                featurePermissionManager?.Dispose();
                subjectManager?.Dispose();
            }
        }
Пример #8
0
 void setcmbGrSbjSubject()
 {
     cmbGrSbjSubject.ValueMember   = "Id";
     cmbGrSbjSubject.DisplayMember = "Name";
     cmbGrSbjSubject.DataSource    = toDataTable(sbj.GetSubjects().ToList());
 }
Пример #9
0
        private async void btn_Done_AddLesson_Click(object sender, RoutedEventArgs e)
        {
            bool       cont                = true;
            int        daynumber           = cmb_Day_AddLesson.SelectedIndex;
            DayOfWeek  day                 = DayOfWeek.Monday;
            bool       day_complete        = true;
            LessonTime lessontime          = LessonTimeManager.GetLessonTimes()[0];
            bool       lessontime_complete = true;
            Subject    subject             = SubjectManager.GetSubjects()[0];
            bool       subject_complete    = true;

            if (daynumber == 0)
            {
                day = DayOfWeek.Monday;
            }
            else if (daynumber == 1)
            {
                day = DayOfWeek.Tuesday;
            }
            else if (daynumber == 2)
            {
                day = DayOfWeek.Wednesday;
            }
            else if (daynumber == 3)
            {
                day = DayOfWeek.Thursday;
            }
            else if (daynumber == 4)
            {
                day = DayOfWeek.Friday;
            }
            else
            {
                day_complete = false;
            }

            if (cmb_LessonTime_AddLesson.SelectedIndex != -1)
            {
                lessontime = (LessonTime)cmb_LessonTime_AddLesson.SelectedItem;
            }
            else
            {
                lessontime_complete = false;
            }

            if (cmb_Subject_AddLesson.SelectedIndex != -1)
            {
                subject = (Subject)cmb_Subject_AddLesson.SelectedItem;
            }
            else
            {
                subject_complete = false;
            }

            if (day_complete == false || lessontime_complete == false || subject_complete == false)
            {
                LessonManager.not_completed_dialog();
            }
            else
            {
                if (LessonManager.GetLesson(day, lessontime) != null)
                {
                    ContentDialogResult result = await LessonManager.already_exists_dialog();

                    if (result == ContentDialogResult.Secondary)
                    {
                        edit_lesson = LessonManager.GetLesson(day, lessontime);
                    }
                    else
                    {
                        cont = false;
                    }
                }
                if (cont)
                {
                    if (edit_lesson != null)
                    {
                        LessonManager.DeleteLesson(edit_lesson.day, edit_lesson.lesson_time);
                    }
                    LessonManager.AddLesson(new Lesson {
                        day = day, lesson_time = lessontime, subject_id = subject.id
                    });
                }
            }
            if (cont)
            {
                Frame.GoBack();
            }
        }
Пример #10
0
        public IHttpActionResult GetSubjects()
        {
            var subjects = manager.GetSubjects();

            return(Ok(subjects));
        }
Пример #11
0
 public Subjects()
 {
     this.InitializeComponent();
     subjects_list = SubjectManager.GetSubjects();
     subjects_list.Sort((x, y) => x.subject_name.CompareTo(y.subject_name));
 }