mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-08 04:48:44 +00:00
Add SlotCardPartial class
This commit is contained in:
parent
db6d0aab31
commit
6dacfc3645
2 changed files with 83 additions and 64 deletions
74
ProjectLighthouse/Pages/Partials/SlotCardPartial.cshtml
Normal file
74
ProjectLighthouse/Pages/Partials/SlotCardPartial.cshtml
Normal file
|
@ -0,0 +1,74 @@
|
|||
@using LBPUnion.ProjectLighthouse
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@model LBPUnion.ProjectLighthouse.Types.Levels.Slot
|
||||
|
||||
@{
|
||||
User user = (User)ViewData["User"];
|
||||
|
||||
await using Database database = new();
|
||||
|
||||
string slotName = string.IsNullOrEmpty(Model.Name) ? "Unnamed Level" : Model.Name;
|
||||
|
||||
bool isQueued = false;
|
||||
bool isHearted = false;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
isQueued = await database.QueuedLevels.FirstOrDefaultAsync(h => h.SlotId == Model.SlotId && h.UserId == user.UserId) != null;
|
||||
|
||||
isHearted = await database.HeartedLevels.FirstOrDefaultAsync(h => h.SlotId == Model.SlotId && h.UserId == user.UserId) != null;
|
||||
}
|
||||
|
||||
string callbackUrl = (string)ViewData["CallbackUrl"];
|
||||
}
|
||||
<div class="ui grid">
|
||||
<div class="eight wide column">
|
||||
<h2 style="margin-bottom: 2px;">@slotName</h2>
|
||||
<div class="statsUnderTitle" style="margin-bottom: 10px;">
|
||||
<i class="pink heart icon" title="Hearts"></i> <span>@Model.Hearts</span>
|
||||
<i class="blue play icon" title="Plays"></i> <span>@Model.Plays</span>
|
||||
<i class="green thumbs up icon" title="Yays"></i> <span>@Model.Thumbsup</span>
|
||||
<i class="red thumbs down icon" title="Boos"></i> <span>@Model.Thumbsdown</span>
|
||||
|
||||
@if (Model.GameVersion == GameVersion.LittleBigPlanet1)
|
||||
{
|
||||
<i class="yellow star icon" title="LBP1 Stars"></i>
|
||||
<span>@Model.RatingLBP1</span>
|
||||
}
|
||||
</div>
|
||||
<p>
|
||||
<i>Created by <a href="/user/@Model.Creator?.UserId">@Model.Creator?.Username</a></i>
|
||||
</p>
|
||||
</div>
|
||||
<div class="eight wide right aligned column">
|
||||
@if (user != null)
|
||||
{
|
||||
if (isHearted)
|
||||
{
|
||||
<a class="ui pink tiny button" href="/slot/@Model.SlotId/unheart?callbackUrl=@callbackUrl" title="Unheart">
|
||||
<i class="broken heart icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="ui pink tiny button" href="/slot/@Model.SlotId/heart?callbackUrl=@callbackUrl" title="Heart">
|
||||
<i class="heart icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
|
||||
if (isQueued)
|
||||
{
|
||||
<a class="ui yellow tiny button" href="/slot/@Model.SlotId/unqueue?callbackUrl=@callbackUrl" title="Unqueue">
|
||||
<i class="bell slash icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="ui yellow tiny button" href="/slot/@Model.SlotId/queue?callbackUrl=@callbackUrl" title="Queue">
|
||||
<i class="bell icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
|
@ -1,7 +1,5 @@
|
|||
@page "/slots/{pageNumber:int}"
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@using LBPUnion.ProjectLighthouse.Types.Levels
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@model LBPUnion.ProjectLighthouse.Pages.SlotsPage
|
||||
|
||||
@{
|
||||
|
@ -13,69 +11,16 @@
|
|||
|
||||
@foreach (Slot slot in Model.Slots)
|
||||
{
|
||||
string slotName = string.IsNullOrEmpty(slot.Name) ? "Unnamed Level" : slot.Name;
|
||||
|
||||
bool isQueued = false;
|
||||
bool isHearted = false;
|
||||
|
||||
if (Model.User != null)
|
||||
{
|
||||
isQueued = await Model.Database.QueuedLevels.FirstOrDefaultAsync(h => h.SlotId == slot.SlotId && h.UserId == Model.User.UserId) != null;
|
||||
|
||||
isHearted = await Model.Database.HeartedLevels.FirstOrDefaultAsync(h => h.SlotId == slot.SlotId && h.UserId == Model.User.UserId) != null;
|
||||
}
|
||||
|
||||
<div class="ui segment">
|
||||
<div class="ui grid">
|
||||
<div class="eight wide column">
|
||||
<h2 style="margin-bottom: 2px;">@slotName</h2>
|
||||
<div class="statsUnderTitle" style="margin-bottom: 10px;">
|
||||
<i class="pink heart icon" title="Hearts"></i> <span>@slot.Hearts</span>
|
||||
<i class="blue play icon" title="Plays"></i> <span>@slot.Plays</span>
|
||||
<i class="green thumbs up icon" title="Yays"></i> <span>@slot.Thumbsup</span>
|
||||
<i class="red thumbs down icon" title="Boos"></i> <span>@slot.Thumbsdown</span>
|
||||
|
||||
@if (slot.GameVersion == GameVersion.LittleBigPlanet1)
|
||||
{
|
||||
<i class="yellow star icon" title="LBP1 Stars"></i>
|
||||
<span>@slot.RatingLBP1</span>
|
||||
}
|
||||
</div>
|
||||
<p>
|
||||
<i>Created by <a href="/user/@slot.Creator?.UserId">@slot.Creator?.Username</a></i>
|
||||
</p>
|
||||
</div>
|
||||
<div class="eight wide right aligned column">
|
||||
@if (Model.User != null)
|
||||
{
|
||||
if (isHearted)
|
||||
{
|
||||
<a class="ui pink tiny button" href="/slot/@slot.SlotId/unheart?callbackUrl=~/slots/@Model.PageNumber" title="Unheart">
|
||||
<i class="broken heart icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="ui pink tiny button" href="/slot/@slot.SlotId/heart?callbackUrl=~/slots/@Model.PageNumber" title="Heart">
|
||||
<i class="heart icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
|
||||
if (isQueued)
|
||||
{
|
||||
<a class="ui yellow tiny button" href="/slot/@slot.SlotId/unqueue?callbackUrl=~/slots/@Model.PageNumber" title="Unqueue">
|
||||
<i class="bell slash icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="ui yellow tiny button" href="/slot/@slot.SlotId/queue?callbackUrl=~/slots/@Model.PageNumber" title="Queue">
|
||||
<i class="bell icon" style="margin: 0"></i>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@await Html.PartialAsync("Partials/SlotCardPartial", slot, new ViewDataDictionary(ViewData)
|
||||
{
|
||||
{
|
||||
"User", Model.User
|
||||
},
|
||||
{
|
||||
"CallbackUrl", $"~/slots/{Model.PageNumber}"
|
||||
},
|
||||
})
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue