Пример #1
0
 /// <summary>
 /// Creates a User.
 /// </summary>
 /// <param name="forename">The forename.</param>
 /// <param name="surname">The surname.</param>
 /// <param name="email">The email.</param>
 /// <param name="password">The password.</param>
 /// <returns></returns>
 public UserAccount Create(string forename, string surname, string email, string password)
 {
     var userAccount = new UserAccount {Id = Guid.NewGuid(), Forname = forename, Surname = surname, EmailAddress = email, Password = password};
     ValidateUser(userAccount);
     _userAccountRepository.Create(userAccount);
     return userAccount;
 }
Пример #2
0
 /// <summary>
 /// Creates a Team.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="players">The players.</param>
 /// <param name="leagueId">The league id.</param>
 /// <param name="user">The user.</param>
 /// <returns></returns>
 public Team Create(string name, IList<Player> players, Guid leagueId, UserAccount user)
 {
     var team = new Team {Id = Guid.NewGuid(), Name = name, Manager = user, Players = players};
     Validate(team);
     _teamRepository.Create(team);
     _leagueRepository.AddTeamToLeague(leagueId, team);
     return team;
 }
Пример #3
0
 private static void InsertDefaultAdmin(ISession session)
 {
     using (session)
     {
         using (var transaction = session.BeginTransaction())
         {
             var adminUser = new UserAccount
             {
                 Id = Guid.NewGuid(),
                 Forname = "Craig",
                 Surname = "Brennan",
                 EmailAddress = "*****@*****.**",
                 Password = "******"
                 };
             session.Save(adminUser);
             transaction.Commit();
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Validates a user.
 /// </summary>
 /// <param name="userAccount">The user account.</param>
 private void ValidateUser(UserAccount userAccount)
 {
     var user = _userAccountRepository.GetUserByEmail(userAccount.EmailAddress);
     if (user != null)
         throw new InvalidEntityException("Email Address already exists.");
 }
Пример #5
0
 /// <summary>
 /// Creates an Article.
 /// </summary>
 /// <param name="title">The title.</param>
 /// <param name="content">The content.</param>
 /// <param name="author">The author.</param>
 /// <returns></returns>
 public Article Create(string title, string content, UserAccount author)
 {
     var article = new Article { Id = Guid.NewGuid(), Title = title, Content = content, Author = author, DateCreated = DateTime.Now };
     _articleRepository.Create(article);
     return article;
 }