Skip to content

Commit

Permalink
New service in CommandLineDbClient: ListLanguages
Browse files Browse the repository at this point in the history
  • Loading branch information
VoltanFr committed Nov 12, 2023
1 parent 1d3108b commit 38d4f4b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions MemCheck.CommandLineDbClient/ManageDB/ListLanguages.cs
Original file line number Diff line number Diff line change
@@ -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<ListUsers> logger;
private readonly MemCheckDbContext dbContext;
#endregion
public ListLanguages(IServiceProvider serviceProvider)
{
dbContext = serviceProvider.GetRequiredService<MemCheckDbContext>();
logger = serviceProvider.GetRequiredService<ILogger<ListUsers>>();
}
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}");
}
}

0 comments on commit 38d4f4b

Please sign in to comment.