예제 #1
0
    /// <summary>
    /// Importing all achievements
    /// </summary>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public async Task <bool> ImportAchievements()
    {
        var connector = new GuidWars2ApiConnector(null);

        await using (connector.ConfigureAwait(false))
        {
            var achievementIds = await connector.GetAllAchievementIds()
                                 .ConfigureAwait(false);

            var achievements = await connector.GetAchievements(achievementIds)
                               .ConfigureAwait(false);

            using (var dbFactory = RepositoryFactory.CreateInstance())
            {
                return(await dbFactory.GetRepository <GuildWarsAchievementRepository>()
                       .BulkInsert(achievements)
                       .ConfigureAwait(false));
            }
        }
    }