public ActionResult SendTest(ExaminationForLevelViewModel model) { if (!ModelState.IsValid) { return(View("SelectStudents", model)); } if (model.Students.Where(x => x.IsChecked == false).Count() == model.Students.Count) { this.ModelState.AddModelError("", Common.ChooseOneStudent); return(View("SelectStudents", model)); } foreach (var item in model.Students) { if (item.IsChecked) { if (!this.levelTestForSolvingService.HasTest(item.Id, model.LevelId)) { this.levelTestForSolvingService.Add(new LevelTestForSolving { CourseLevelId = model.LevelId, StudentId = item.Id }); } var student = this.studentService.GetById(item.Id); this.notificationService.Add(new Notification { UserId = student.ApplicationUserId, Content = "^d3357bfa357649c2859fd8041a445ef4^", Link = "/LevelTestForSolving" }); } } return(Redirect("/")); }
public ActionResult SelectStudents(int id) { if (this.BellongToCurrentUser(id)) { var courseId = this.courseLevelService.GetById(id).CourseId; var students = this.studentService.GetStudentsWithoutCourseLevelForCourse(id, courseId); var convertedStudents = students.ToList().ConvertAll(x => new StudentViewModel { FullName = x.ApplicationUser.FirstName + " " + x.ApplicationUser.SecondName + " " + x.ApplicationUser.LastName, Id = x.Id, IsChecked = false }).ToList(); var viewModel = new ExaminationForLevelViewModel { LevelId = id, Students = convertedStudents }; return(View(viewModel)); } return(Redirect("/")); }