Esempio n. 1
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 }));
        }