コード例 #1
0
		public async Task<IActionResult> Admins(string className)
		{
			var classroom = await ClassroomService.GetClassroomAsync(className);
			var admins = await ClassroomService.GetClassroomAdminsAsync(className);

			var viewModel = new UserListViewModel
			(
				admins.Select(admin => admin.User).ToList(),
				new List<UserAction>()
				{
						new UserAction
						(
							"Remove",
							user => Url.Action("RemoveAdmin", new {userId = user.Id})
						)
				}
			);

			ViewBag.Classroom = classroom;
			ViewBag.ClassroomRole = ClassroomRole.Admin;

			return View(viewModel);
		}
コード例 #2
0
		public async Task<IActionResult> Students(string sectionName)
		{
			var section = Classroom.Sections
				.SingleOrDefault(s => s.Name == sectionName);

			if (section == null)
			{
				return NotFound();
			}

			var students = await SectionService.GetSectionStudentsAsync
			(
				ClassroomName,
				sectionName
			);

			var studentsViewModel = new UserListViewModel
			(
				students
					.Select(m => m.ClassroomMembership.User)
					.OrderBy(u => u.LastName)
					.ThenBy(u => u.FirstName)
					.ToList(),

				new List<UserAction>()
				{
					new UserAction
					(
						"Assignments",
						user => Url.Action("StudentReport", "Assignment", new {userId = user.Id})
					),
					new UserAction
					(
						"Projects",
						user => Url.Action("Status", "Project", new {userId = user.Id})
					),
					new UserAction
					(
						"View",
						user => Url.Action("View", "User", new {userId = user.Id})
					),
					new UserAction
					(
						"Edit",
						user => Url.Action("Edit", "User", new {userId = user.Id})
					),
					new UserAction
					(
						"Remove",
						user => Url.Action("RemoveStudent", new {userId = user.Id})
					)
				}
			);

			ViewBag.Section = section;

			return View(studentsViewModel);
		}