Основа для ASP-сайта для просмотра сущностей
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eWeb.Pages;
|
||||
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
|
||||
public readonly Pf2eDbContext Context;
|
||||
|
||||
public Dictionary<EntityType, int> Data { get; set; } = new();
|
||||
|
||||
public IndexModel(ILogger<IndexModel> logger, Pf2eDbContext context)
|
||||
{
|
||||
_logger = logger;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
Data = Context
|
||||
.Entities.GroupBy(e => e.Type)
|
||||
.ToDictionary(entities => entities.Key, entities => entities.Count());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user