Skip to content

Commit

Permalink
Movie module - Show RomHash Region, if not null (#1090)
Browse files Browse the repository at this point in the history
* Movie module - show rom region, if not null

* Japan not JPN

* show rom version too

* don't put a v

* asdf

* having fun yet?

* account for more things that could go wrong
  • Loading branch information
adelikat committed Feb 10, 2022
1 parent 625e44c commit 075a2cd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 3 additions & 1 deletion TASVideos/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ 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,
RomVersion = p.Rom != null ? p.Rom.Version : null
});

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

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

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

@functions{
static string RomAndVersionDisplay(string? version, string? region)
{
string regionDisplay = RegionDisplay(region);
if (string.IsNullOrWhiteSpace(version) && string.IsNullOrWhiteSpace(regionDisplay))
{
return "";
}

if (string.IsNullOrWhiteSpace(regionDisplay))
{
return version ?? "";
}

if (string.IsNullOrWhiteSpace(version))
{
return regionDisplay;
}

return $"{regionDisplay}, {version}";
}

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

return region switch
{
"J" => "Japan",
"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 +71,13 @@
}
</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">
@{
var regionAndVersion = RomAndVersionDisplay(Model.RomVersion, Model.Region);
}
<small condition="!string.IsNullOrWhiteSpace(regionAndVersion)"> (@regionAndVersion)</small>
@Model.Title
</span></a>
</h4>
</div>
</cardheader>
Expand Down

0 comments on commit 075a2cd

Please sign in to comment.