@using Lieb.Data @using Lieb.Models @using Lieb.Models.GuildWars2 @using Lieb.Models.GuildWars2.Raid @inject RaidService RaidService @inject UserService UserService @{ bool flexExists = _raid.SignUps.Where(s => s.SignUpType == SignUpType.Flex).Any(); } @if (flexExists) { } @{ bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff && s.LiebUserId > 0).Any(); } @foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.RaidRoleId)) { //leere random Rolle verstecken, wenn sie nicht dem angemeldeten Benutzer gehört bool roleHidden = _raid.RaidType != RaidType.Planned && !role.Role.IsRandomSignUpRole && !_raid.SignUps.Where(s => s.RaidRoleId == role.Role.RaidRoleId && (s.SignUpType != SignUpType.SignedOff || s.LiebUserId == _liebUserId)).Any(); @{ } @if (flexExists) { List flexSignUpTypes =new List(){SignUpType.Flex}; } @if(_liebUserId > 0 && _isRaidSignUpAllowed) { bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.Role.RaidRoleId, SignUpType.SignedUp, false); bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed; @if (isSignedUp && _raid.RaidType == RaidType.Planned) { } } }
@if(_allExpanded) { } else { } Role UsersFlex(@_raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count()/@_raid.Roles.Sum(r => r.Spots))
@code { [Parameter] public RaidDetails _Parent { get; set; } [Parameter] public Raid _raid { get; set; } [Parameter] public LiebUser? _user { get; set; } [Parameter] public bool _isRaidSignUpAllowed { get; set; } private ulong _liebUserId { get; set; } = 0; private List _usableAccounts; private List _expandableRoles; private bool _allExpanded = false; private class ExpandableRole { public RaidRole Role; public bool IsRowExpanded = false; } protected override async Task OnParametersSetAsync() { if (_user != null) { _usableAccounts = UserService.GetAllUsableAccounts(_user.Id, _raid.RaidType); _liebUserId = _user.Id; } _expandableRoles = new List(); foreach(RaidRole role in _raid.Roles) { _expandableRoles.Add(new ExpandableRole() { Role = role }); } } async Task SignUpClicked(RaidRole role, SignUpType signUpType) { if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex) { await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType, _raid.RaidType); } else { int gw2AccountId = UserService.GetMainAccount(_liebUserId).GuildWars2AccountId; if(!_usableAccounts.Where(a => a.GuildWars2AccountId == gw2AccountId).Any()) { gw2AccountId = _usableAccounts.FirstOrDefault().GuildWars2AccountId; } await RaidService.SignUp(_raid.RaidId, _liebUserId, gw2AccountId, role.RaidRoleId, signUpType); } _Parent.HasChanged(); } public async Task ChangeAccount(ChangeEventArgs e) { int accountId = int.Parse(e.Value.ToString()); await RaidService.ChangeAccount(_raid.RaidId, _liebUserId, accountId); _raid = RaidService.GetRaid(_raid.RaidId); this.StateHasChanged(); } private async Task ToggleRow(ExpandableRole role) { role.IsRowExpanded = !role.IsRowExpanded; _allExpanded = !_expandableRoles.Where(r => !r.IsRowExpanded).Any(); } private async Task ToggleAll() { foreach(ExpandableRole role in _expandableRoles) { role.IsRowExpanded = !_allExpanded; } _allExpanded = !_allExpanded; } }