Beispiel #1
0
 public static User MapAuthorRegisterDtoToUser(AuthorRegisteringDto dto)
 {
     return new User()
     {
         Nickname = dto.Nickname,
         AccessToken = dto.PublishCode,
         Role = UserRole.Author,
         HaikusRatingSum = 0.0,
         HaikusCount = 0
     };
 }
Beispiel #2
0
 public async Task RegisterAuthorAsync(AuthorRegisteringDto dto)
 {
     var alreadyRegistered = await this.unitOfWork.UsersRepository
         .GetUniqueAsync(u => u.Nickname == dto.Nickname).ConfigureAwait(false);
     if (alreadyRegistered != null)
     {
         throw new DuplicateNicknameException("Nickname is taken.");
     }
     User user = Mapper.MapAuthorRegisterDtoToUser(dto);
     this.unitOfWork.UsersRepository.Add(user);
     await this.unitOfWork.CommitAsync().ConfigureAwait(false);
 }