Update gestione vocabolario con FusionCache

This commit is contained in:
Samuele Locatelli
2026-05-29 08:33:43 +02:00
parent f697e2413a
commit 75e91dbc79
8 changed files with 153 additions and 68 deletions
+23 -8
View File
@@ -2627,21 +2627,36 @@ namespace MP.Data.Controllers
}
/// <summary>
/// Elenco Vocabolario (completo)
/// Elenco Vocabolario di una lingua
/// </summary>
/// <returns></returns>
public List<VocabolarioModel> VocabolarioGetAll()
public Dictionary<string, string> VocabolarioGetLang(string lingua)
{
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
using (var dbCtx = new MoonProContext(options))
{
dbResult = dbCtx
using var dbCtx = new MoonProContext(options);
var rawList = dbCtx
.DbSetVocabolario
.AsNoTracking()
.Where(x => x.Lingua.ToLower() == lingua.ToLower())
.OrderBy(x => x.Lemma)
.ToList();
}
return dbResult;
// Proietto in dizionario
return rawList
.DistinctBy(t => t.Lemma, StringComparer.OrdinalIgnoreCase)
.ToDictionary(t => t.Lemma, t => t.Traduzione, StringComparer.OrdinalIgnoreCase);
}
/// <summary>
/// Elenco Vocabolario (completo) async
/// </summary>
/// <returns></returns>
public async Task<List<VocabolarioModel>> VocabolarioGetAllAsync()
{
using var dbCtx = new MoonProContext(options);
return await dbCtx
.DbSetVocabolario
.AsNoTracking()
.OrderBy(x => x.Lemma)
.ToListAsync() ?? new();
}
/// <summary>