Example #1
0
 public Comment(User author, string text)
 {
     this.Author = author;
     this.Text = text;
 }
        public string RegisterUser(string username, string password, string confirmPassword)
        {
            if (this.Data.LoggedUser != null)
            {
                return "There is already a logged in user";
            }

            if (password != confirmPassword)
            {
                return "The provided passwords do not match";
            }

            if (this.Data.UsersByUsername.ContainsKey(username))
            {
                return string.Format("A user with username {0} already exists", username);
            }

            var user = new User(username, password);
            this.Data.UsersByUsername.Add(username, user);
            return string.Format("User {0} registered successfully", username);
        }