(type);
+ System.Diagnostics.Debug.WriteLine($"EntityType resolved to: {entityType}");
+
+ // Находим сущность по slug и типу
+ Entity? entity = _context.Entities.FirstOrDefault(e =>
+ e.Slug.ToLower() == slug.ToLower() && e.Type == entityType
+ );
+
+ if (entity == null)
+ {
+ System.Diagnostics.Debug.WriteLine($"Entity not found: type={entityType}, slug={slug}");
+ return NotFound();
+ }
+
+ System.Diagnostics.Debug.WriteLine($"Entity found: {entity.Id} - {entity.Name[Pf2e.Database.Model.Common.I18n.LocaleType.English]}");
+
+ // Создаём FullEntity
+ FullEntity = new(_context, entity);
+
+ // Сериализуем для отображения
+ EntitySerializer serializer = new();
+ SerializationResult = serializer.Serialize(FullEntity);
+
+ return Page();
+ }
+ catch (Exception ex)
+ {
+ System.Diagnostics.Debug.WriteLine($"Error in EntityModel.OnGet: {ex.Message}");
return NotFound();
}
-
- // Создаём FullEntity
- FullEntity = new(_context, entity);
-
- // Сериализуем для отображения
- EntitySerializer serializer = new();
- SerializationResult = serializer.Serialize(FullEntity);
-
- return Page();
}
}
}
diff --git a/Pf2e/Web/Pages/EntityType.cshtml b/Pf2e/Web/Pages/EntityType.cshtml
index 9316c02..0de3b66 100644
--- a/Pf2e/Web/Pages/EntityType.cshtml
+++ b/Pf2e/Web/Pages/EntityType.cshtml
@@ -1,4 +1,4 @@
-@page
+@page "/{type}"
@using Pf2e.Database.Model.Common.I18n
@model EntityTypeModel
@@ -45,7 +45,10 @@
@Html.DisplayFor(modelItem => item.Id)
|
-
+ @{
+ var typeName = Pf2e.Web.Helpers.PgNameHelper.GetPgName(item.Type);
+ }
+
@Html.DisplayFor(modelItem => item.Name[LocaleType.English])
|
@@ -75,14 +78,17 @@
\ No newline at end of file
+
diff --git a/Pf2e/Web/Pages/EntityType.cshtml.cs b/Pf2e/Web/Pages/EntityType.cshtml.cs
index bbc8fad..7be9ff6 100644
--- a/Pf2e/Web/Pages/EntityType.cshtml.cs
+++ b/Pf2e/Web/Pages/EntityType.cshtml.cs
@@ -10,8 +10,11 @@ using Pf2e.Database;
using Pf2e.Database.Model.Base;
using Pf2e.Database.Model.Enum;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
namespace Pf2e.Web.Pages
{
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class EntityTypeModel : PageModel
{
private readonly Pf2eDbContext _context;
@@ -22,7 +25,7 @@ namespace Pf2e.Web.Pages
}
[BindProperty(SupportsGet = true)]
- public int? PageNum { get; set; }
+ public int? PageNum { get; set; } = 1;
public IList Entity { get; set; } = default!;
@@ -34,11 +37,24 @@ namespace Pf2e.Web.Pages
public const int PerPage = 30;
- public void OnGet(string type)
+ public IActionResult OnGet(string type)
{
- CurrentType = Enum(type);
+ // Добавим отладочную информацию
+ System.Diagnostics.Debug.WriteLine($"EntityTypeModel.OnGet called with type: {type}");
+
+ try
+ {
+ CurrentType = Enum(type);
+ System.Diagnostics.Debug.WriteLine($"CurrentType resolved to: {CurrentType}");
+ }
+ catch (Exception ex)
+ {
+ System.Diagnostics.Debug.WriteLine($"Error resolving enum: {ex.Message}");
+ return NotFound();
+ }
int count = _context.Entities.Count(entity => entity.Type == CurrentType);
+ System.Diagnostics.Debug.WriteLine($"Count for {CurrentType}: {count}");
LastPage = (int)Math.Ceiling(count / (double)PerPage);
@@ -47,6 +63,9 @@ namespace Pf2e.Web.Pages
.Skip((CurrentPage - 1) * PerPage)
.Take(PerPage)
.ToList();
+
+ System.Diagnostics.Debug.WriteLine($"Returning page with {Entity.Count} entities");
+ return Page();
}
///
@@ -57,6 +76,8 @@ namespace Pf2e.Web.Pages
public static T Enum(string value)
where T : Enum
{
+ System.Diagnostics.Debug.WriteLine($"Trying to resolve enum value: {value} for type {typeof(T)}");
+
foreach (System.Reflection.FieldInfo field in typeof(T).GetFields())
{
List variants = [field.Name];
@@ -69,8 +90,11 @@ namespace Pf2e.Web.Pages
variants.Add(pgAttribute.PgName);
}
+ System.Diagnostics.Debug.WriteLine($"Checking field: {field.Name}, variants: {string.Join(", ", variants)}");
+
if (variants.Contains(value))
{
+ System.Diagnostics.Debug.WriteLine($"Matched field: {field.Name}");
return (T)field.GetValue(null)!;
}
}
diff --git a/Pf2e/Web/Pages/Index.cshtml b/Pf2e/Web/Pages/Index.cshtml
index 3c49a0e..bf53529 100644
--- a/Pf2e/Web/Pages/Index.cshtml
+++ b/Pf2e/Web/Pages/Index.cshtml
@@ -21,7 +21,10 @@
{
|
-
+ @{
+ var typeName = Pf2e.Web.Helpers.PgNameHelper.GetPgName(row.Key);
+ }
+
@row.Key
|
@@ -29,4 +32,4 @@
}
-
\ No newline at end of file
+