private UserDto MapFromDatabaseDto(UserDatabaseDto dto)
 {
     return new UserDto
     {
         Login = dto.Login,
         Roles = dto.Roles.Select(role => role.Value).ToArray()
     };
 }
Exemplo n.º 2
0
 private async Task TrySaveAsync(DatabaseUserDto dto)
 {
     try
     {
         dbContext.Users.Add(dto);
         await dbContext.SaveChangesAsync();
     }
     catch (DbUpdateException e)
     {
         e.ThrowIfDublicateEntry(new UserException($"Attempt to save dublicate of user with login {dto.Login}"));
         throw;
     }
 }