diff --git a/MemCheck.CommandLineDbClient/ManageDB/ListLanguages.cs b/MemCheck.CommandLineDbClient/ManageDB/ListLanguages.cs new file mode 100644 index 00000000..813d0365 --- /dev/null +++ b/MemCheck.CommandLineDbClient/ManageDB/ListLanguages.cs @@ -0,0 +1,32 @@ +using MemCheck.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Threading.Tasks; + +namespace MemCheck.CommandLineDbClient.ManageDB; + +internal sealed class ListLanguages : ICmdLinePlugin +{ + #region Fields + private readonly ILogger logger; + private readonly MemCheckDbContext dbContext; + #endregion + public ListLanguages(IServiceProvider serviceProvider) + { + dbContext = serviceProvider.GetRequiredService(); + logger = serviceProvider.GetRequiredService>(); + } + public void DescribeForOpportunityToCancel() + { + logger.LogInformation("Will list languages"); + } + public async Task RunAsync() + { + var languages = await dbContext.CardLanguages.ToListAsync(); + + foreach (var language in languages) + logger.LogInformation($"Language '{language.Name}' has id {language.Id}"); + } +}