예제 #1
0
        /// <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);
        }
예제 #2
0
 public Logout(User user)
     : base(user)
 {
 }
예제 #3
0
 public Register(User user)
     : base(user)
 {
 }
예제 #4
0
 public UsersController(IBangaloreUniversityData data, User user)
 {
     this.Data = data;
     this.Usr = user;
 }
예제 #5
0
 public Login(User user)
     : base(user)
 {
 }
예제 #6
0
 public void AddStudent(User student)
 {
     this.Students.Add(student);
 }
예제 #7
0
 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;
 }
예제 #9
0
 public void AddStudent(User student)
 {
     this.Students.Add(student);
     student.Courses.Add(this);
 }