Exemplo n.º 1
0
 public WhoIsModule(DiscordSocketClient client, XIVApi xivApi, MasterSpriggansDatabaseContext db)
 {
     _xivApi = xivApi;
     _db     = db;
     _client = client;
 }
Exemplo n.º 2
0
        public static async Task SeedDatabase(MasterSpriggansDatabaseContext context, XIVApi xivApi)
        {
            //  Get the list of titles from the XIVApi
            Logger.Message("Downloading title list, this may take a moment...");
            TitleListResponseModel titleListResponse = await xivApi.GetTitlesList();

            if (titleListResponse.Error.HasValue)
            {
                throw new Exception(titleListResponse.Message);
            }
            else
            {
                Logger.Message("Inserting titles into database...");
                foreach (var title in titleListResponse.Results)
                {
                    await context.AddAsync(new XIVTitleModel()
                    {
                        ID = title.ID, Name = title.Name
                    });
                }

                await context.SaveChangesAsync();
            }
        }