Exemple #1
0
 public UserModel(UserRolesInfo userRoles)
 {
     UserName        = userRoles.UserName;
     UserId          = userRoles.UserId;
     UserVisibleName = userRoles.UserVisibleName;
     CourseAccesses  = new DefaultDictionary <string, Dictionary <CourseAccessType, CourseAccessModel> >();
     SystemAccesses  = new Dictionary <SystemAccessType, SystemAccessModel>();
 }
Exemple #2
0
 public UserModel(UserRolesInfo userRoles)
 {
     UserName  = userRoles.UserName;
     UserId    = userRoles.UserId;
     GroupName = userRoles.GroupName;
 }
Exemple #3
0
		private UserModel GetUserModel(UserRolesInfo userRoles, Dictionary<string, Dictionary<CourseRole, List<string>>> coursesForUsers, List<string> courses)
		{
			var user = new UserModel(userRoles)
			{
				CoursesAccess = new Dictionary<string, ICoursesAccessListModel>
				{
					{
						LmsRoles.SysAdmin,
						new SingleCourseAccessModel
						{
							HasAccess = userRoles.Roles.Contains(LmsRoles.SysAdmin),
							ToggleUrl = Url.Action("ToggleSystemRole", new { userId = userRoles.UserId, role = LmsRoles.SysAdmin })
						}
					}
				}
			};

			Dictionary<CourseRole, List<string>> coursesForUser;
			if (!coursesForUsers.TryGetValue(userRoles.UserId, out coursesForUser))
				coursesForUser = new Dictionary<CourseRole, List<string>>();

			foreach (var role in Enum.GetValues(typeof(CourseRole)).Cast<CourseRole>().Where(roles => roles != CourseRole.Student))
			{
				user.CoursesAccess[role.ToString()] = new ManyCourseAccessModel
				{
					CoursesAccesses = courses
						.Select(s => new CourseAccessModel
						{
							CourseId = s,
							HasAccess = coursesForUser.ContainsKey(role) && coursesForUser[role].Contains(s),
							ToggleUrl = Url.Action("ToggleRole", new { courseId = s, userId = user.UserId, role })
						})
						.ToList()
				};
			}
			return user;
		}
Exemple #4
0
		public UserModel(UserRolesInfo userRoles)
		{
			UserName = userRoles.UserName;
			UserId = userRoles.UserId;
			UserVisibleName = userRoles.UserVisibleName;
		}
Exemple #5
0
		public UserModel(UserRolesInfo userRoles)
		{
			UserName = userRoles.UserName;
			UserId = userRoles.UserId;
			GroupName = userRoles.GroupName;
		}
Exemple #6
0
 public UserModel(UserRolesInfo userRoles)
 {
     UserName        = userRoles.UserName;
     UserId          = userRoles.UserId;
     UserVisibleName = userRoles.UserVisibleName;
 }