コード例 #1
0
        public virtual ActionResult Edit(ParentCourseGradesModel parentCourseGradesModel)
        {
            if (!ModelState.IsValid)
            {
                return View(parentCourseGradesModel);
            }
            if (parentCourseGradesModel.FindParentCourseModel.ParentCourseId == null ||
                parentCourseGradesModel.FindParentCourseModel.SessionId == null) 
                return View(parentCourseGradesModel);

            var students = _parentCourseRepository.GetStudents((int)parentCourseGradesModel.FindParentCourseModel.SessionId, (Guid)parentCourseGradesModel.FindParentCourseModel.ParentCourseId);

            _parentCourseRepository.GetParentCourseGrades((Guid) parentCourseGradesModel.FindParentCourseModel.ParentCourseId, (int) parentCourseGradesModel.FindParentCourseModel.SessionId);

            var studentsToBeGraded =  students.Where(
                s =>
                    parentCourseGradesModel.ParentGradesModelList.Any(
                        gradeModel => gradeModel.StudentUSI == s.StudentUSI)).ToList();

            _parentCourseGradesModelToStudentsMapper.Map(parentCourseGradesModel, studentsToBeGraded);

            _genericRepository.Save();

            return RedirectToAction(MVC.ParentCourseGrade.Get(parentCourseGradesModel.FindParentCourseModel.SessionId, parentCourseGradesModel.FindParentCourseModel.ParentCourseId));
        }
コード例 #2
0
        public void Map(ParentCourseGradesModel parentCourseGradesModel, List<Data.Entities.Student> studentsToBeGraded)
        {
            var parentCourseId = (Guid)parentCourseGradesModel.FindParentCourseModel.ParentCourseId;
            var sesssionId = (int) parentCourseGradesModel.FindParentCourseModel.SessionId;

            foreach (var student in studentsToBeGraded)
            {
                if (!student.ParentCourseGrades.IsNullOrEmpty() &&
                    student.ParentCourseGrades.Any(pcg => pcg.ParentCourseId == parentCourseId && pcg.Session.SessionIdentity == sesssionId ))
                {

                    var parentCourseGrade = student.ParentCourseGrades.FirstOrDefault( p =>
                            p.ParentCourseId == parentCourseGradesModel.FindParentCourseModel.ParentCourseId &&
                            p.Session.SessionIdentity == parentCourseGradesModel.FindParentCourseModel.SessionId);

                    _parentCourseGradeModelToParentCourseGradeMapper.Map(parentCourseGradesModel, student.StudentUSI, parentCourseGrade);

                }
                else
                {
                    var parentCourseGradeForStudent = _parentCourseGradeModelToParentCourseGradeMapper.Build(parentCourseGradesModel, student.StudentUSI);
                    student.ParentCourseGrades.Add(parentCourseGradeForStudent);
                }
            }
        }
コード例 #3
0
        public ParentCourseGrade Build(ParentCourseGradesModel parentCourseGradesModel, int studentUsi)
        {
            var session = _sesssionRepository.GetById((int)parentCourseGradesModel.FindParentCourseModel.SessionId);

            var parentCourseGrade = new ParentCourseGrade
            {
                ParentCourseId = (Guid)parentCourseGradesModel.FindParentCourseModel.ParentCourseId,
                SchoolYear = session.SchoolYear,
                TermTypeId = session.TermTypeId,
                SchoolId = session.SchoolId
            };

            Map(parentCourseGradesModel, studentUsi, parentCourseGrade);
            return parentCourseGrade;
        }
コード例 #4
0
        public ParentCourseGrade Build(ParentCourseGradesModel parentCourseGradesModel, int studentUsi)
        {
            var session = _sesssionRepository.GetById((int)parentCourseGradesModel.FindParentCourseModel.SessionId);

            var parentCourseGrade = new ParentCourseGrade
            {
                ParentCourseId = (Guid)parentCourseGradesModel.FindParentCourseModel.ParentCourseId,
                SchoolYear     = session.SchoolYear,
                TermTypeId     = session.TermTypeId,
                SchoolId       = session.SchoolId
            };

            Map(parentCourseGradesModel, studentUsi, parentCourseGrade);
            return(parentCourseGrade);
        }
        public ParentCourseGradesModel Build(List <Data.Entities.Student> students, Data.Entities.Session session, Data.Entities.ParentCourse parentCourse)
        {
            var findParentCourseModel = _sectionToFindParentCourseModelMapper.Build(session, t =>
            {
                t.ParentCourse   = parentCourse.ParentCourseCode + " - " + parentCourse.ParentCourseTitle;
                t.ParentCourseId = parentCourse.Id;
            });

            var grades = students.SelectMany(s => s.ParentCourseGrades);

            var parentGradesModelList = grades.Select(g => _parentCourseGradeToGradeModelMapper.Build(g)).ToList();
            var studentsInParentCourseWithoutGrades = students.Where(s => s.ParentCourseGrades.IsNullOrEmpty()).ToList();

            parentGradesModelList = parentGradesModelList.Concat(studentsInParentCourseWithoutGrades.Select(s => _studentToGradeModelMapper.Build(s))).ToList();


            var parentCourseGradesModel = new ParentCourseGradesModel();

            parentCourseGradesModel.FindParentCourseModel = findParentCourseModel;
            parentCourseGradesModel.ParentGradesModelList = parentGradesModelList.ToList();

            return(parentCourseGradesModel);
        }
コード例 #6
0
        public void Map(ParentCourseGradesModel parentCourseGradesModel, List <Data.Entities.Student> studentsToBeGraded)
        {
            var parentCourseId = (Guid)parentCourseGradesModel.FindParentCourseModel.ParentCourseId;
            var sesssionId     = (int)parentCourseGradesModel.FindParentCourseModel.SessionId;

            foreach (var student in studentsToBeGraded)
            {
                if (!student.ParentCourseGrades.IsNullOrEmpty() &&
                    student.ParentCourseGrades.Any(pcg => pcg.ParentCourseId == parentCourseId && pcg.Session.SessionIdentity == sesssionId))
                {
                    var parentCourseGrade = student.ParentCourseGrades.FirstOrDefault(p =>
                                                                                      p.ParentCourseId == parentCourseGradesModel.FindParentCourseModel.ParentCourseId &&
                                                                                      p.Session.SessionIdentity == parentCourseGradesModel.FindParentCourseModel.SessionId);

                    _parentCourseGradeModelToParentCourseGradeMapper.Map(parentCourseGradesModel, student.StudentUSI, parentCourseGrade);
                }
                else
                {
                    var parentCourseGradeForStudent = _parentCourseGradeModelToParentCourseGradeMapper.Build(parentCourseGradesModel, student.StudentUSI);
                    student.ParentCourseGrades.Add(parentCourseGradeForStudent);
                }
            }
        }
        public ParentCourseGradesModel Build(List<Data.Entities.Student> students, Data.Entities.Session session, Data.Entities.ParentCourse parentCourse)
        {

            var findParentCourseModel = _sectionToFindParentCourseModelMapper.Build(session, t =>
            {
                t.ParentCourse = parentCourse.ParentCourseCode +" - "+ parentCourse.ParentCourseTitle;
                t.ParentCourseId = parentCourse.Id;
            });

            var grades = students.SelectMany(s => s.ParentCourseGrades);

            var parentGradesModelList = grades.Select(g => _parentCourseGradeToGradeModelMapper.Build(g)).ToList();
            var studentsInParentCourseWithoutGrades = students.Where(s => s.ParentCourseGrades.IsNullOrEmpty()).ToList();

            parentGradesModelList = parentGradesModelList.Concat(studentsInParentCourseWithoutGrades.Select(s => _studentToGradeModelMapper.Build(s))).ToList();


           var parentCourseGradesModel = new ParentCourseGradesModel();

            parentCourseGradesModel.FindParentCourseModel = findParentCourseModel;
            parentCourseGradesModel.ParentGradesModelList = parentGradesModelList.ToList();

            return parentCourseGradesModel;
        }
コード例 #8
0
        public void Map(ParentCourseGradesModel source, int studentUsi, ParentCourseGrade target)
        {

                target.GradeEarned = FindGradeOfStudentInParentGradesModelList(source.ParentGradesModelList, studentUsi);
        }
コード例 #9
0
 public void Map(ParentCourseGradesModel source, int studentUsi, ParentCourseGrade target)
 {
     target.GradeEarned = FindGradeOfStudentInParentGradesModelList(source.ParentGradesModelList, studentUsi);
 }