@model WritingContextDisplayViewModel @{ var scene = Model.Context!.Scene!; var floorPlan = Model.FloorPlan; var floorId = scene.InitialFloorPlanFloorID ?? floorPlan?.OccupancyScenes.FirstOrDefault(x => x.SceneID == scene.SceneID)?.InitialFloorPlanFloorID ?? floorPlan?.Floors.OrderBy(x => x.SortOrder).FirstOrDefault()?.FloorPlanFloorID; var floor = floorPlan?.Floors.FirstOrDefault(x => x.FloorPlanFloorID == floorId); var blocks = floor is null ? [] : floorPlan!.Blocks.Where(x => x.FloorPlanFloorID == floor.FloorPlanFloorID).ToList(); var tokens = floor is null ? [] : floorPlan!.OccupancyTokens.Where(x => x.SceneID == scene.SceneID && x.FloorPlanFloorID == floor.FloorPlanFloorID).ToList(); var tokensByLocation = tokens.GroupBy(x => x.LocationID).ToDictionary(x => x.Key, x => x.ToList()); static string TextOr(string? value, string fallback) => string.IsNullOrWhiteSpace(value) ? fallback : value.Trim(); }

Location

@TextOr(scene.LocationOptions.FirstOrDefault(x => x.Value == scene.PrimaryLocationID?.ToString())?.Text, "No primary location")

Floor plan
@(floorPlan?.FloorPlan.Name ?? "No floor plan linked to this scene")
Floor
@(floor?.Name ?? "No floor selected")

Occupancy

@if (floorPlan is null) {

No floor plan linked to this scene.

} else if (floor is null || !blocks.Any()) {

No placed rooms are available for this floor.

} else {
@foreach (var block in blocks) { var locationTokens = block.LocationID.HasValue && tokensByLocation.TryGetValue(block.LocationID.Value, out var blockTokens) ? blockTokens : [];
@block.DisplayLabel @if (locationTokens.Any()) { @string.Join(", ", locationTokens.Select(x => x.DisplayName).Take(3))@(locationTokens.Count > 3 ? $" +{locationTokens.Count - 3}" : string.Empty) }
}
}

Characters

@if (!scene.SceneCharacters.Any(x => !string.IsNullOrWhiteSpace(x.LocationName) || !string.IsNullOrWhiteSpace(x.LocationPath))) {

No character locations recorded.

} else { }

Assets

@if (!scene.SceneAssetLocations.Any() && !scene.AssetCustodyEvents.Any()) {

No asset locations or custody changes recorded.

} else { }