206 lines
8.3 KiB
Text
206 lines
8.3 KiB
Text
@using System.Security.Claims
|
|
@using Lieb.Data
|
|
@using Lieb.Models
|
|
@using Lieb.Models.GuildWars2.Raid
|
|
@inject UserService UserService
|
|
@inject RaidService RaidService
|
|
|
|
<body>
|
|
<h5>@Raid.Title</h5>
|
|
|
|
<div>@Raid.Description</div>
|
|
|
|
<div >
|
|
<div class="times">
|
|
<h5>Date</h5>
|
|
<p>@Raid.Date.ToLongDateString()</p>
|
|
</div>
|
|
<div class="times">
|
|
<h5>Time</h5>
|
|
<p>from: @Raid.StartTime.LocalDateTime.ToShortTimeString() to: @Raid.EndTime.LocalDateTime.ToShortTimeString()</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="details">
|
|
<h5>Organizer</h5>
|
|
<p>@Raid.Organizer</p>
|
|
</div>
|
|
<div class="details">
|
|
<h5>Guild</h5>
|
|
<p>@Raid.Guild</p>
|
|
</div>
|
|
<div class="details">
|
|
<h5>Voice chat</h5>
|
|
<p>@Raid.VoiceChat</p>
|
|
</div>
|
|
</div>
|
|
|
|
<AuthorizeView>
|
|
<Authorized>
|
|
@{
|
|
ulong discordId = ulong.Parse(@context.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
|
|
LiebUser user = UserService.GetLiebUserSmall(discordId);
|
|
RaidSignUp userRole = Raid.SignUps.Where(s => s.LiebUserId == user.LiebUserId).FirstOrDefault();
|
|
bool isSignedUp = userRole != null;
|
|
|
|
<table class="table">
|
|
<tbody>
|
|
@foreach (var role in Raid.Roles)
|
|
{
|
|
Models.GuildWars2.Raid.RaidSignUp[] signUps = Raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
|
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
|
|
|
<tr>
|
|
@if (@usedSpots < @role.Spots)
|
|
{
|
|
<td><button @onclick="() => SignUpClicked(role, user, isSignedUp)">Sign Up</button></td>
|
|
<td><button @onclick="() => MaybeClicked(role, user, isSignedUp)">Maybe</button></td>
|
|
}
|
|
else
|
|
{
|
|
<td></td>
|
|
<td></td>
|
|
}
|
|
<td><button @onclick="() => BackupClicked(role, user, isSignedUp)">Backup</button></td>
|
|
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
|
|
|
</tr>
|
|
|
|
@foreach (var signUp in signUps)
|
|
{
|
|
@if(signUp.SignUpType != SignUpType.SignedOff)
|
|
{
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == user.LiebUserId;}
|
|
@if(isUser)
|
|
{
|
|
<td><button @onclick="() => SignOffClicked(role, user)">Sign Off</button></td>
|
|
}
|
|
else
|
|
{
|
|
<td></td>
|
|
}
|
|
@{string signUpStatus = string.Empty;}
|
|
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
|
|
|
@if (isUser)
|
|
{
|
|
<td>@signUp.LiebUser.Name
|
|
<select value=@signUp.GuildWars2AccountId @onchange="args => ChangeAccount(user, args)">
|
|
@foreach (var account in user.GuildWars2Accounts)
|
|
{
|
|
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
|
|
}
|
|
</select> @signUpStatus </td>
|
|
}
|
|
else
|
|
{
|
|
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
|
|
}
|
|
</tr>
|
|
}
|
|
}
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
</Authorized>
|
|
<NotAuthorized>
|
|
<div>
|
|
<table class="table">
|
|
<tbody>
|
|
@foreach (var role in Raid.Roles)
|
|
{
|
|
Models.GuildWars2.Raid.RaidSignUp[] signUps = Raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
|
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
|
|
|
<tr>
|
|
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
|
</tr>
|
|
@foreach (var signUp in signUps)
|
|
{
|
|
if(signUp.SignUpType != SignUpType.SignedOff)
|
|
{
|
|
string signUpStatus = string.Empty;
|
|
if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
|
<tr>
|
|
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
|
|
</tr>
|
|
}
|
|
}
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</NotAuthorized>
|
|
</AuthorizeView>
|
|
<AuthorizeView Policy="RaidLead">
|
|
<div class="nav-item px-3">
|
|
@{string navLink = $"raidedit/{@Raid.RaidId}";}
|
|
<NavLink class="nav-link" href="@navLink">
|
|
<span class="oi oi-plus" aria-hidden="true"></span> Edit
|
|
</NavLink>
|
|
</div>
|
|
</AuthorizeView>
|
|
</body>
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public Raid Raid { get; set; }
|
|
|
|
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp)
|
|
{
|
|
if(isSignedUp)
|
|
{
|
|
await RaidService.ChangeSignUpType(Raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp);
|
|
}
|
|
else
|
|
{
|
|
await RaidService.SignUp(Raid.RaidId, liebUser.LiebUserId, liebUser.GuildWars2Accounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, SignUpType.SignedUp);
|
|
}
|
|
Raid = RaidService.GetRaid(Raid.RaidId);
|
|
}
|
|
|
|
async Task BackupClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp)
|
|
{
|
|
if(isSignedUp)
|
|
{
|
|
await RaidService.ChangeSignUpType(Raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, SignUpType.Backup);
|
|
}
|
|
else
|
|
{
|
|
await RaidService.SignUp(Raid.RaidId, liebUser.LiebUserId, liebUser.GuildWars2Accounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, SignUpType.Backup);
|
|
}
|
|
Raid = RaidService.GetRaid(Raid.RaidId);
|
|
}
|
|
|
|
async Task MaybeClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp)
|
|
{
|
|
if(isSignedUp)
|
|
{
|
|
await RaidService.ChangeSignUpType(Raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, SignUpType.Maybe);
|
|
}
|
|
else
|
|
{
|
|
await RaidService.SignUp(Raid.RaidId, liebUser.LiebUserId, liebUser.GuildWars2Accounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, SignUpType.Maybe);
|
|
}
|
|
Raid = RaidService.GetRaid(Raid.RaidId);
|
|
}
|
|
|
|
async Task SignOffClicked(PlannedRaidRole role, LiebUser liebUser)
|
|
{
|
|
await RaidService.SignOff(Raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId);
|
|
Raid = RaidService.GetRaid(Raid.RaidId);
|
|
}
|
|
|
|
async Task ChangeAccount(LiebUser liebUser, ChangeEventArgs e)
|
|
{
|
|
int accountId = int.Parse(e.Value.ToString());
|
|
await RaidService.ChangeAccount(Raid.RaidId, liebUser.LiebUserId, accountId);
|
|
Raid = RaidService.GetRaid(Raid.RaidId);
|
|
}
|
|
}
|