예제 #1
0
 public void TestLogoutViewDisplay()
 {
     const string Username = "******";
     const string Password = "******";
     string expectedResult = string.Format("User {0} logged out successfully.", Username);
     var user = new User(Username, Password, Role.Lecturer);
     var view = new LogoutView(user);
     string actualResult = view.Display();
     Assert.AreEqual(expectedResult, actualResult);
 }
예제 #2
0
        public Controller Create(string controllerType, IBangaloreUniversityDate data, User user)
        {
            switch (controllerType)
            {
                case "UsersController":
                    return new UsersController(data, user);
                case "CoursesController":
                    return new CoursesController(data, user);
            }

            return null;
        }
        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();

            var 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);
            var user = new User(username, password, userRole);
            this.Data.Users.Add(user);
            return this.View(user);
        }
예제 #4
0
 public void AddStudent(User student)
 {
     this.Students.Add(student);
     student.Courses.Add(this);
 }
예제 #5
0
 public Login(User user)
     : base(user)
 {
 }
 public CoursesController(IBangaloreUniversityDate data, User user)
 {
     this.Data = data;
     this.CurrentUser = user;
 }
예제 #7
0
 public Logout(User user)
     : base(user)
 {
 }
예제 #8
0
 /// <summary>Initializes a new instance of the <see cref="UsersController"/> class.</summary>
 /// <param name="data">The data.</param>
 /// <param name="user">The user.</param>
 public UsersController(IBangaloreUniversityDate data, User user)
 {
     this.Data = data;
     this.User = user;
 }
예제 #9
0
 protected UserView(User user)
 {
     this.User = user;
 }
예제 #10
0
 public RegisterView(User user)
     : base(user)
 {
 }
예제 #11
0
 public LogoutView(User user)
     : base(user)
 {
 }
예제 #12
0
 public LoginView(User user)
     : base(user)
 {
 }