Продолжаем работать с билдером

This commit is contained in:
2025-10-07 18:28:45 +04:00
parent 95345c940f
commit 99952c66e3
15 changed files with 1055 additions and 517 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
@page "/{type}/{slug}"
@model Pf2e.Web.Pages.EntityModel
@model Pf2e.Web.Pages.Entity
@{
ViewData["Title"] = "Entity";
@@ -26,10 +26,10 @@
{
<span class="badge bg-warning text-dark">НЕ РЕАЛИЗОВАНО:</span>
}
@Html.Raw(field.DisplayValue)
@Html.Raw(field.Value)
</dd>
}
</dl>
</div>
</div>
}
}
+9 -9
View File
@@ -16,22 +16,22 @@ using Pf2e.Web.Helpers;
namespace Pf2e.Web.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class EntityModel(Pf2eDbContext context) : PageModel
public class Entity(Pf2eDbContext context) : PageModel
{
private readonly Pf2eDbContext _context = context;
public FullEntity FullEntity { get; set; } = null!;
public EntitySerializer.SerializationResult SerializationResult { get; set; } = null!;
public Pf2e.Web.Helpers.Serialization.SerializationResult SerializationResult { get; set; } = null!;
public IActionResult OnGet(string type, string slug)
{
// Добавим отладочную информацию
System.Diagnostics.Debug.WriteLine(
$"EntityModel.OnGet called with type: {type}, slug: {slug}"
$"Entity.OnGet called with type: {type}, slug: {slug}"
);
// Логируем в консоль для веб-сервера
Console.WriteLine($"EntityModel.OnGet called with type: {type}, slug: {slug}");
Console.WriteLine($"Entity.OnGet called with type: {type}, slug: {slug}");
try
{
@@ -41,7 +41,7 @@ namespace Pf2e.Web.Pages
Console.WriteLine($"EntityType resolved to: {entityType}");
// Находим сущность по slug и типу
Entity? entity = _context
Database.Model.Base.Entity? entity = _context
.Entities.AsNoTracking()
.FirstOrDefault(e =>
e.Slug.ToLower() == slug.ToLower() && e.Type == entityType
@@ -67,7 +67,7 @@ namespace Pf2e.Web.Pages
FullEntity = new(_context, entityType, entity.Id);
// Сериализуем для отображения
EntitySerializer serializer = new();
EntitySerialization serializer = new();
SerializationResult = serializer.Serialize(FullEntity);
// Set breadcrumbs
@@ -76,15 +76,15 @@ namespace Pf2e.Web.Pages
{
("Home", "/"),
(entityType.ToString(), $"/{typeName}"),
(entity.Name[Pf2e.Database.Model.Common.I18n.LocaleType.English], "")
(entity.Name[Pf2e.Database.Model.Common.I18n.LocaleType.English], ""),
};
return Page();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error in EntityModel.OnGet: {ex.Message}");
Console.WriteLine($"Error in EntityModel.OnGet: {ex.Message}");
System.Diagnostics.Debug.WriteLine($"Error in Entity.OnGet: {ex.Message}");
Console.WriteLine($"Error in Entity.OnGet: {ex.Message}");
return NotFound();
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Pf2e.Web.Pages
[BindProperty(SupportsGet = true)]
public int? PageNum { get; set; } = 1;
public IList<Entity> Entity { get; set; } = null!;
public IList<Database.Model.Base.Entity> Entity { get; set; } = null!;
public EntityType CurrentType;