Глобальный рефакторинг пространств имён
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pf2e.Database;
|
||||
using Pf2e.Database.Model;
|
||||
using Pf2e.Database.Model.Base;
|
||||
using Pf2e.Database.Model.Enum;
|
||||
using Pf2e.Database.Model.Structure;
|
||||
|
||||
namespace Pf2e.Web.Pages
|
||||
{
|
||||
public class EntityModel : PageModel
|
||||
{
|
||||
private readonly Pf2e.Database.Pf2eDbContext _context;
|
||||
|
||||
public EntityModel(Pf2e.Database.Pf2eDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IEntity Entity;
|
||||
|
||||
public Dictionary<string, string> Fields = [];
|
||||
|
||||
public Dictionary<string, List<Entity>> References = [];
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string type, string slug)
|
||||
{
|
||||
Entity entity =
|
||||
_context
|
||||
.Entities.Where(e =>
|
||||
e.Slug == slug && e.Type == EntityTypeModel.Enum<EntityType>(type)
|
||||
)
|
||||
.Include(e => e.Sources)
|
||||
.ThenInclude(s => s.Source)
|
||||
.Include(e => e.Keywords)
|
||||
.Include(e => e.Externals)
|
||||
.ThenInclude(x => x.Target)
|
||||
.Include(e => e.Traits)
|
||||
.ThenInclude(t => t.Entity)
|
||||
.FirstOrDefault() ?? throw new("Entity is null");
|
||||
/*
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var class = await _context.Classes.FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if (class is not null)
|
||||
{
|
||||
Class = class;
|
||||
|
||||
return Page();
|
||||
}
|
||||
*/
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user