Skip to content

Commit

Permalink
Movie module - show rom region, if not null
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Feb 9, 2022
1 parent 8cd5e68 commit 6d8fb47
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion TASVideos/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public static IQueryable<PublicationDisplayModel> ToViewModel(this IQueryable<Pu
OverallRating = p.PublicationRatings
.Where(pr => !pr.Publication!.Authors.Select(a => a.UserId).Contains(pr.UserId))
.Where(pr => pr.User!.UseRatings)
.Average(pr => pr.Value)
.Average(pr => pr.Value),
Region = p.Rom != null ? p.Rom.Region : null
});

if (ratingSort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class PublicationDisplayModel

public int RatingCount { get; set; }
public double? OverallRating { get; set; }
public string? Region { get; set; }

public class TagModel
{
Expand Down
22 changes: 21 additions & 1 deletion TASVideos/Pages/Shared/_MovieModule.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
var publicationAwards = await _awards.ForPublication(Model.Id);
}

@functions{
static string RegionDisplay(string? region)
{
if (string.IsNullOrWhiteSpace(region))
{
return "";
}

return region switch
{
"J" => "(JPN)",
"E" => "(Europe)",
"EU" => "(USA/Europe)",
_ => ""
};
}
}

<card class="border border-primary">
<cardheader class="bg-cardprimary p-2">
<div class="gx-3 clearfix">
Expand All @@ -32,7 +50,9 @@
}
</div>
<h4>
<a asp-page="/Publications/View" asp-route-id="@Model.Id" class="text-decoration-none"><span class="text-dark">@Model.Title </span></a>
<a asp-page="/Publications/View" asp-route-id="@Model.Id" class="text-decoration-none"><span class="text-dark">
<small condition="!string.IsNullOrWhiteSpace(Model.Region)">@RegionDisplay(Model.Region)</small> @Model.Title
</span></a>
</h4>
</div>
</cardheader>
Expand Down

0 comments on commit 6d8fb47

Please sign in to comment.