Обновления веб-отображения
This commit is contained in:
@@ -26,39 +26,65 @@ namespace Pf2e.Web.Pages
|
||||
public IActionResult OnGet(string type, string slug)
|
||||
{
|
||||
// Добавим отладочную информацию
|
||||
System.Diagnostics.Debug.WriteLine($"EntityModel.OnGet called with type: {type}, slug: {slug}");
|
||||
|
||||
System.Diagnostics.Debug.WriteLine(
|
||||
$"EntityModel.OnGet called with type: {type}, slug: {slug}"
|
||||
);
|
||||
|
||||
// Логируем в консоль для веб-сервера
|
||||
Console.WriteLine($"EntityModel.OnGet called with type: {type}, slug: {slug}");
|
||||
|
||||
try
|
||||
{
|
||||
// Получаем тип сущности
|
||||
EntityType entityType = EntityTypeModel.Enum<EntityType>(type);
|
||||
System.Diagnostics.Debug.WriteLine($"EntityType resolved to: {entityType}");
|
||||
Console.WriteLine($"EntityType resolved to: {entityType}");
|
||||
|
||||
// Находим сущность по slug и типу
|
||||
Entity? entity = _context.Entities.FirstOrDefault(e =>
|
||||
e.Slug.ToLower() == slug.ToLower() && e.Type == entityType
|
||||
);
|
||||
Entity? entity = _context
|
||||
.Entities.AsNoTracking()
|
||||
.FirstOrDefault(e =>
|
||||
e.Slug.ToLower() == slug.ToLower() && e.Type == entityType
|
||||
);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Entity not found: type={entityType}, slug={slug}");
|
||||
System.Diagnostics.Debug.WriteLine(
|
||||
$"Entity not found: type={entityType}, slug={slug}"
|
||||
);
|
||||
Console.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]}");
|
||||
System.Diagnostics.Debug.WriteLine(
|
||||
$"Entity found: {entity.Id} - {entity.Name[Pf2e.Database.Model.Common.I18n.LocaleType.English]}"
|
||||
);
|
||||
Console.WriteLine(
|
||||
$"Entity found: {entity.Id} - {entity.Name[Pf2e.Database.Model.Common.I18n.LocaleType.English]}"
|
||||
);
|
||||
|
||||
// Создаём FullEntity
|
||||
FullEntity = new(_context, entity);
|
||||
FullEntity = new(_context, entityType, entity.Id);
|
||||
|
||||
// Сериализуем для отображения
|
||||
EntitySerializer serializer = new();
|
||||
SerializationResult = serializer.Serialize(FullEntity);
|
||||
|
||||
// Set breadcrumbs
|
||||
var typeName = Pf2e.Web.Helpers.PgNameHelper.GetPgName(entityType);
|
||||
ViewData["Breadcrumbs"] = new List<(string, string)>
|
||||
{
|
||||
("Home", "/"),
|
||||
(entityType.ToString(), $"/{typeName}"),
|
||||
(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}");
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user