/// <summary> /// Registers the specified user. /// </summary> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <param name="confirmPassword">The password confirmation.</param> /// <param name="role">The user role.</param> /// <returns></returns> /// <exception cref="ArgumentException"> /// The provided passwords do not match. /// or /// A user with this username already exists. /// </exception> public IView Register(string username, string password, string confirmPassword, string role) { if (password != confirmPassword) { throw new ArgumentException("The provided passwords do not match."); } this.EnsureNoLoggedInUser(); User existingUser = this.Data.Users.GetByUsername(username); if (existingUser != null) { throw new ArgumentException(string.Format("A user with username {0} already exists.", username)); } Role userRole = (Role)Enum.Parse(typeof(Role), role, true); User user = new User(username, password, userRole); this.Data.Users.Add(user); return this.View(user); }
public Logout(User user) : base(user) { }
public Register(User user) : base(user) { }
public UsersController(IBangaloreUniversityData data, User user) { this.Data = data; this.Usr = user; }
public Login(User user) : base(user) { }
public void AddStudent(User student) { this.Students.Add(student); }
public Logout Constructor(User user) { Logout target = new Logout(user); Assert.IsNotNull(target); return target; }
public CoursesController(IBangaloreUniversityData data, User currentUser) { this.Data = data; this.CurrentUser = currentUser; }
public void AddStudent(User student) { this.Students.Add(student); student.Courses.Add(this); }