public async Task <IActionResult> AssignStudents(string id) { var userId = this.userManager.GetUserId(this.User); var students = await this.userService.GetAllStudentsAsync <StudentViewModel>(userId); var model = new GroupWithStudentsViewModel() { Id = id, Students = students }; return(this.View(model)); }
public async Task <IActionResult> AddStudents(GroupWithStudentsViewModel model) { var studentsIds = model.Students.Where(x => x.IsAssigned).Select(x => x.Id).ToList(); if (studentsIds.Count() == 0) { model.Error = true; return(this.View(model)); } await this.service.AssignStudentsToGroupAsync(model.Id, studentsIds); return(this.RedirectToAction("GroupDetails", new { id = model.Id })); }
public async Task <IActionResult> AddStudents(string id) { IList <StudentViewModel> students; var isDashboardRequest = this.HttpContext.Session.GetString(GlobalConstants.DashboardRequest) != null; if (isDashboardRequest) { students = await this.userService.GetAllStudentsAsync <StudentViewModel>(null, id); } else { var userId = this.userManager.GetUserId(this.User); students = await this.userService.GetAllStudentsAsync <StudentViewModel>(userId, id); } var model = new GroupWithStudentsViewModel() { Id = id, Students = students }; model.Students = students; return(this.View(model)); }