/// <summary> /// Main Method /// </summary> /// <param name="args"></param> /// <returns></returns> public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <JokesDbContext>(); await JokesGenerator.Initialize(services); } host.Run(); }
static async Task Main(string[] args) { JokesGenerator jokesGenerator = new JokesGenerator(); string randomJoke = await jokesGenerator.GetRandomJoke(); Console.WriteLine(randomJoke); string[] categories = await jokesGenerator.GetCategories(); for (int index = categories.Length - 1; index >= 0; index--) { Console.WriteLine(categories[index]); } }
private void Button_Click(object sender, RoutedEventArgs e) { JokesGenerator jokesGenerator = new JokesGenerator(); string randomJoke = await jokesGenerator.GetRandomJoke(); }