Ejemplo n.º 1
0
        public ActionResult Details(int ClassId)
        {
            var adminRole = new AdminRole();
            var students  = adminRole.GetStudentsOfClass(ClassId).Select(x => new StudentSubscriptionVM {
                StudentId = x.StudentId, Name = $"{x.StudentName}, {x.StudentFirstName}", Subscribed = true
            }).ToList();
            var ViewValue = new ClassWithStudentsVM {
                Classe = adminRole.GetClass(ClassId), Students = students
            };

            return(View(ViewValue));
        }
Ejemplo n.º 2
0
        public ActionResult ListStudent(int ClassId)
        {
            var adminRole = new AdminRole();

            // var students = adminRole.GetStudents().Except(adminRole.GetStudentsOfClass(ClassId)).ToList();
            var students = adminRole.GetStudents().Select(x => new StudentSubscriptionVM {
                StudentId = x.StudentId, Name = $"{x.StudentName}, {x.StudentFirstName}", Subscribed = false
            }).ToList();
            var studentsSubscribed = adminRole.GetStudentsOfClass(ClassId).ToList();

            students.ForEach(x => x.Subscribed = studentsSubscribed.Any(y => y.StudentId == x.StudentId));
            var ViewValue = new ClassWithStudentsVM {
                Classe = adminRole.GetClass(ClassId), Students = students
            };



            return(View(ViewValue));//ajouter page de selection
        }
Ejemplo n.º 3
0
        public ActionResult ListStudentSav(ClassWithStudentsVM maClasseStudent)
        {
            var adminRole = new AdminRole();

            adminRole.UpdateClassAttendence(maClasseStudent.Classe.ClassId, maClasseStudent.Students.Where(x => x.Subscribed == true).Select(x => adminRole.GetStudent(x.StudentId)).ToList());

            //var existingStudent = adminRole.GetStudentsOfClass(maClasseStudent.Classe.ClassId).Select(x=>x.StudentId);
            //var deletedStudent = Queryable.Except<Student>(existingStudent.AsQueryable(), maClasseStudent.Students.Where(x=>x.Subscribed == true).Select(x => x.StudentId)).ToList();
            ////var addedStudent = maClasseStudent.Students.Where(a => a.Subscribed == true);

            //for (var i = 0; i < maClasseStudent.Students.Count(); i++)
            //{
            //    if  (maClasseStudent.Students[i].Subscribed == false)
            //    {
            //        var ViewValue1 = adminRole.RemoveStudent(maClasseStudent.Classe.ClassId, maClasseStudent.Students[i].StudentId);
            //    }
            //    else
            //    {
            //        var ViewValue2 = adminRole.AddStudent2(adminRole.GetClass(maClasseStudent.Classe.ClassId), adminRole.GetStudent(maClasseStudent.Students[i].StudentId));
            //    }
            //}

            return(RedirectToAction("Details", new { ClassId = maClasseStudent.Classe.ClassId }));
        }