Random Messages don't show empty roles
No Flex Button in random raids Reworked random sign up to keep roles after signing off
This commit is contained in:
parent
0c319a0a8a
commit
2288e48308
7 changed files with 161 additions and 70 deletions
|
@ -36,9 +36,12 @@ namespace DiscordBot.Messages
|
||||||
var builder = new ComponentBuilder()
|
var builder = new ComponentBuilder()
|
||||||
.WithButton("SignUp", $"{Constants.ComponentIds.SIGN_UP_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Success)
|
.WithButton("SignUp", $"{Constants.ComponentIds.SIGN_UP_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Success)
|
||||||
.WithButton("Maybe", $"{Constants.ComponentIds.MAYBE_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Secondary)
|
.WithButton("Maybe", $"{Constants.ComponentIds.MAYBE_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Secondary)
|
||||||
.WithButton("Backup", $"{Constants.ComponentIds.BACKUP_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Secondary)
|
.WithButton("Backup", $"{Constants.ComponentIds.BACKUP_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Secondary);
|
||||||
.WithButton("Flex", $"{Constants.ComponentIds.FLEX_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Secondary)
|
if(raid.AllowFlexRole)
|
||||||
.WithButton("SignOff", $"{Constants.ComponentIds.SIGN_OFF_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Danger);
|
{
|
||||||
|
builder.WithButton("Flex", $"{Constants.ComponentIds.FLEX_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Secondary);
|
||||||
|
}
|
||||||
|
builder.WithButton("SignOff", $"{Constants.ComponentIds.SIGN_OFF_BUTTON}-{raid.RaidId.ToString()}", ButtonStyle.Danger);
|
||||||
|
|
||||||
MessageComponent components = builder.Build();
|
MessageComponent components = builder.Build();
|
||||||
Embed raidMessage = CreateRaidMessage(raid);
|
Embed raidMessage = CreateRaidMessage(raid);
|
||||||
|
|
|
@ -73,12 +73,25 @@ namespace Lieb.Controllers
|
||||||
Raid raid = _raidService.GetRaid(raidId);
|
Raid raid = _raidService.GetRaid(raidId);
|
||||||
|
|
||||||
List<ApiRole> apiRoles = new List<ApiRole>();
|
List<ApiRole> apiRoles = new List<ApiRole>();
|
||||||
|
if(raid.RaidType == RaidType.Planned)
|
||||||
|
{
|
||||||
foreach(RaidRole role in raid.Roles)
|
foreach(RaidRole role in raid.Roles)
|
||||||
{
|
{
|
||||||
apiRoles.Add(new ApiRole(){
|
apiRoles.Add(new ApiRole(){
|
||||||
Name = role.Name,
|
Name = role.Name,
|
||||||
Description = role.Description,
|
Description = role.Description,
|
||||||
IsSignUpAllowed = _raidService.IsRoleSignUpAllowed(userId, role.RaidRoleId, SignUpType.SignedUp),
|
IsSignUpAllowed = _raidService.IsRoleSignUpAllowed(raidId, userId, role.RaidRoleId, SignUpType.SignedUp, false),
|
||||||
|
roleId = role.RaidRoleId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RaidRole role = raid.Roles.First(r => r.IsRandomSignUpRole);
|
||||||
|
apiRoles.Add(new ApiRole(){
|
||||||
|
Name = role.Name,
|
||||||
|
Description = role.Description,
|
||||||
|
IsSignUpAllowed = _raidService.IsRoleSignUpAllowed(raidId, userId, role.RaidRoleId, SignUpType.SignedUp, false),
|
||||||
roleId = role.RaidRoleId
|
roleId = role.RaidRoleId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,8 @@ namespace Lieb.Data
|
||||||
VoiceChat = raid.VoiceChat,
|
VoiceChat = raid.VoiceChat,
|
||||||
StartTimeUTC = raid.StartTimeUTC,
|
StartTimeUTC = raid.StartTimeUTC,
|
||||||
EndTimeUTC = raid.EndTimeUTC,
|
EndTimeUTC = raid.EndTimeUTC,
|
||||||
RaidId = raid.RaidId
|
RaidId = raid.RaidId,
|
||||||
|
AllowFlexRole = raid.RaidType == RaidType.Planned
|
||||||
};
|
};
|
||||||
apiRaid.DisocrdMessages = ConvertMessages(raid.DiscordRaidMessages);
|
apiRaid.DisocrdMessages = ConvertMessages(raid.DiscordRaidMessages);
|
||||||
apiRaid.Roles = new List<ApiRaid.Role>();
|
apiRaid.Roles = new List<ApiRaid.Role>();
|
||||||
|
@ -353,8 +354,11 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(raid.RaidType == RaidType.Planned || role.IsRandomSignUpRole || apiRole.Users.Count > 0)
|
||||||
|
{
|
||||||
apiRaid.Roles.Add(apiRole);
|
apiRaid.Roles.Add(apiRole);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return apiRaid;
|
return apiRaid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Lieb.Models;
|
using Lieb.Models;
|
||||||
|
using Lieb.Models.GuildWars2;
|
||||||
using Lieb.Models.GuildWars2.Raid;
|
using Lieb.Models.GuildWars2.Raid;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -107,11 +108,22 @@ namespace Lieb.Data
|
||||||
|
|
||||||
public async Task<bool> SignUp(int raidId, ulong liebUserId, int guildWars2AccountId, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId = 0)
|
public async Task<bool> SignUp(int raidId, ulong liebUserId, int guildWars2AccountId, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId = 0)
|
||||||
{
|
{
|
||||||
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
Raid? raid = context.Raids
|
||||||
|
.Include(r => r.Roles)
|
||||||
|
.Include(r => r.SignUps)
|
||||||
|
.FirstOrDefault(r => r.RaidId == raidId);
|
||||||
|
if(raid == null) return false;
|
||||||
|
if(raid.RaidType != RaidType.Planned)
|
||||||
|
{
|
||||||
|
return await SignUpRandom(raidId, liebUserId, guildWars2AccountId, signUpType, signedUpByUserId);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
using var context = _contextFactory.CreateDbContext();
|
|
||||||
LiebUser user = context.LiebUsers.FirstOrDefault(l => l.Id == liebUserId);
|
LiebUser user = context.LiebUsers.FirstOrDefault(l => l.Id == liebUserId);
|
||||||
|
|
||||||
if(user == null) return false;
|
if(user == null) return false;
|
||||||
|
@ -119,7 +131,7 @@ namespace Lieb.Data
|
||||||
List<RaidSignUp> signUps = context.RaidSignUps.Where(r => r.RaidId == raidId && r.LiebUserId == liebUserId).ToList();
|
List<RaidSignUp> signUps = context.RaidSignUps.Where(r => r.RaidId == raidId && r.LiebUserId == liebUserId).ToList();
|
||||||
if (signUpType != SignUpType.Flex && signUps.Where(r => r.SignUpType != SignUpType.Flex).Any())
|
if (signUpType != SignUpType.Flex && signUps.Where(r => r.SignUpType != SignUpType.Flex).Any())
|
||||||
{
|
{
|
||||||
await ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType, false);
|
await ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType, raid.RaidType, false);
|
||||||
await ChangeAccount(raidId, liebUserId, guildWars2AccountId, false);
|
await ChangeAccount(raidId, liebUserId, guildWars2AccountId, false);
|
||||||
}
|
}
|
||||||
else if (!signUps.Where(r => r.RaidRoleId == plannedRoleId).Any())
|
else if (!signUps.Where(r => r.RaidRoleId == plannedRoleId).Any())
|
||||||
|
@ -139,6 +151,46 @@ namespace Lieb.Data
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SignUpRandom(int raidId, ulong liebUserId, int guildWars2AccountId, SignUpType signUpType, ulong signedUpByUserId = 0)
|
||||||
|
{
|
||||||
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
if(signUpType == SignUpType.Flex) return false;
|
||||||
|
|
||||||
|
Raid? raid = context.Raids
|
||||||
|
.Include(r => r.Roles)
|
||||||
|
.Include(r => r.SignUps)
|
||||||
|
.FirstOrDefault(r => r.RaidId == raidId);
|
||||||
|
|
||||||
|
GuildWars2Account account = context.GuildWars2Accounts
|
||||||
|
.Include(a => a.EquippedBuilds)
|
||||||
|
.ThenInclude(b => b.GuildWars2Build)
|
||||||
|
.FirstOrDefault(a => a.GuildWars2AccountId == guildWars2AccountId);
|
||||||
|
|
||||||
|
if(account == null) return false;
|
||||||
|
if(!account.EquippedBuilds.Where(b => b.GuildWars2Build.UseInRandomRaid).Any()) return false;
|
||||||
|
|
||||||
|
if(IsRandomRoleSignUpAllowed(raid, liebUserId, signUpType))
|
||||||
|
{
|
||||||
|
RaidSignUp signUp;
|
||||||
|
if(raid.SignUps.Where(s => s.LiebUserId == liebUserId).Any())
|
||||||
|
{
|
||||||
|
signUp = raid.SignUps.First(s => s.LiebUserId == liebUserId);
|
||||||
|
signUp.SignUpType = signUpType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RaidRole randomRole = raid.Roles.First(r => r.IsRandomSignUpRole);
|
||||||
|
signUp = new RaidSignUp(raid.RaidId, liebUserId, guildWars2AccountId, randomRole.RaidRoleId , signUpType);
|
||||||
|
context.RaidSignUps.Add(signUp);
|
||||||
|
}
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
await LogSignUp(signUp, context.LiebUsers.FirstOrDefault(u => u.Id == liebUserId)?.Name, signedUpByUserId);
|
||||||
|
await _discordService.PostRaidMessage(raidId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> SignUpExternalUser(int raidId, string userName, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId)
|
public async Task<bool> SignUpExternalUser(int raidId, string userName, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId)
|
||||||
{
|
{
|
||||||
if (!IsRoleSignUpAllowed(raidId, ulong.MaxValue, plannedRoleId, signUpType, true))
|
if (!IsRoleSignUpAllowed(raidId, ulong.MaxValue, plannedRoleId, signUpType, true))
|
||||||
|
@ -168,14 +220,6 @@ namespace Lieb.Data
|
||||||
if (signUp != null)
|
if (signUp != null)
|
||||||
{
|
{
|
||||||
signUp.SignUpType = SignUpType.SignedOff;
|
signUp.SignUpType = SignUpType.SignedOff;
|
||||||
|
|
||||||
//change and delete Role for Random Raids
|
|
||||||
Raid? raid = context.Raids.Include(r => r.Roles).FirstOrDefault(r => r.RaidId == raidId);
|
|
||||||
if(raid != null && raid.RaidType != RaidType.Planned && !signUp.RaidRole.IsRandomSignUpRole)
|
|
||||||
{
|
|
||||||
context.RaidRoles.Remove(signUp.RaidRole);
|
|
||||||
signUp.RaidRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole, CreateRandomSignUpRole(raid.RaidType));
|
|
||||||
}
|
|
||||||
await LogSignUp(signUp, signUp.LiebUser.Name, signedOffByUserId);
|
await LogSignUp(signUp, signUp.LiebUser.Name, signedOffByUserId);
|
||||||
}
|
}
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
@ -214,7 +258,7 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ChangeSignUpType(int raidId, ulong liebUserId, int plannedRoleId, SignUpType signUpType, bool postChanges = true)
|
public async Task ChangeSignUpType(int raidId, ulong liebUserId, int plannedRoleId, SignUpType signUpType, RaidType raidType, bool postChanges = true)
|
||||||
{
|
{
|
||||||
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
||||||
{
|
{
|
||||||
|
@ -236,8 +280,11 @@ namespace Lieb.Data
|
||||||
|
|
||||||
//change to new role
|
//change to new role
|
||||||
if (signUp != null)
|
if (signUp != null)
|
||||||
|
{
|
||||||
|
if(raidType == RaidType.Planned)
|
||||||
{
|
{
|
||||||
signUp.RaidRoleId = plannedRoleId;
|
signUp.RaidRoleId = plannedRoleId;
|
||||||
|
}
|
||||||
signUp.SignUpType = signUpType;
|
signUp.SignUpType = signUpType;
|
||||||
if(signUp.IsExternalUser)
|
if(signUp.IsExternalUser)
|
||||||
{
|
{
|
||||||
|
@ -255,7 +302,35 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRoleSignUpAllowed(ulong liebUserId, int plannedRoleId, SignUpType signUpType)
|
public bool IsRoleSignUpAllowed(int raidId, ulong liebUserId, int plannedRoleId, SignUpType signUpType, bool moveFlexUser)
|
||||||
|
{
|
||||||
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
Raid? raid = context.Raids
|
||||||
|
.Include(r => r.Roles)
|
||||||
|
.Include(r => r.SignUps)
|
||||||
|
.FirstOrDefault(r => r.RaidId == raidId);
|
||||||
|
|
||||||
|
if (raid == null) return false;
|
||||||
|
|
||||||
|
if (raid.RaidType == RaidType.Planned)
|
||||||
|
{
|
||||||
|
if (raid.MoveFlexUsers)
|
||||||
|
{
|
||||||
|
//moveFlexUser parameter is for only checking or really moving
|
||||||
|
return IsRoleSignUpAllowedMoveFlex(raid, liebUserId, plannedRoleId, signUpType, moveFlexUser, new List<int>()).Result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return IsRoleSignUpAllowedBasicCheck(liebUserId, plannedRoleId, signUpType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return IsRandomRoleSignUpAllowed(raid, liebUserId, signUpType, plannedRoleId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsRoleSignUpAllowedBasicCheck(ulong liebUserId, int plannedRoleId, SignUpType signUpType)
|
||||||
{
|
{
|
||||||
if(signUpType == SignUpType.Backup || signUpType == SignUpType.Flex || signUpType == SignUpType.SignedOff)
|
if(signUpType == SignUpType.Backup || signUpType == SignUpType.Flex || signUpType == SignUpType.SignedOff)
|
||||||
{
|
{
|
||||||
|
@ -278,47 +353,9 @@ namespace Lieb.Data
|
||||||
return signUps.Where(s => s.LiebUserId == liebUserId && s.SignUpType == SignUpType.SignedUp).Any();
|
return signUps.Where(s => s.LiebUserId == liebUserId && s.SignUpType == SignUpType.SignedUp).Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRoleSignUpAllowed(int raidId, ulong liebUserId, int plannedRoleId, SignUpType signUpType, bool moveFlexUser)
|
private async Task<bool> IsRoleSignUpAllowedMoveFlex(Raid raid, ulong liebUserId, int plannedRoleId, SignUpType signUpType, bool moveFlexUser, List<int> checkedRoleIds)
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
if (IsRoleSignUpAllowedBasicCheck(liebUserId, plannedRoleId, signUpType))
|
||||||
Raid? raid = context.Raids
|
|
||||||
.Include(r => r.Roles)
|
|
||||||
.Include(r => r.SignUps)
|
|
||||||
.FirstOrDefault(r => r.RaidId == raidId);
|
|
||||||
|
|
||||||
if (raid == null) return false;
|
|
||||||
|
|
||||||
if (raid.RaidType == RaidType.Planned)
|
|
||||||
{
|
|
||||||
if (raid.MoveFlexUsers)
|
|
||||||
{
|
|
||||||
return IsRoleSignUpAllowed(raid, liebUserId, plannedRoleId, signUpType, moveFlexUser, new List<int>()).Result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return IsRoleSignUpAllowed(liebUserId, plannedRoleId, signUpType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RaidRole? role = context.RaidRoles
|
|
||||||
.AsNoTracking()
|
|
||||||
.FirstOrDefault(r => r.RaidRoleId == plannedRoleId);
|
|
||||||
if(role == null) return false;
|
|
||||||
if (role.IsRandomSignUpRole)
|
|
||||||
{
|
|
||||||
// new sign up is available if there are free spots and the user is not signed up or still in the random role
|
|
||||||
RaidSignUp? signUp = raid.SignUps.FirstOrDefault(s => s.LiebUserId == liebUserId);
|
|
||||||
return raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < role.Spots
|
|
||||||
&& (signUp == null || signUp.RaidRoleId == plannedRoleId || signUp.SignUpType == SignUpType.SignedOff);
|
|
||||||
}
|
|
||||||
return raid.SignUps.Where(s => s.LiebUserId == liebUserId && s.RaidRoleId == plannedRoleId).Any();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<bool> IsRoleSignUpAllowed(Raid raid, ulong liebUserId, int plannedRoleId, SignUpType signUpType, bool moveFlexUser, List<int> checkedRoleIds)
|
|
||||||
{
|
|
||||||
if (IsRoleSignUpAllowed(liebUserId, plannedRoleId, signUpType))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (checkedRoleIds == null)
|
if (checkedRoleIds == null)
|
||||||
|
@ -335,11 +372,11 @@ namespace Lieb.Data
|
||||||
foreach (RaidSignUp signUp in raid.SignUps.Where(s => s.LiebUserId == userId && s.SignUpType == SignUpType.Flex))
|
foreach (RaidSignUp signUp in raid.SignUps.Where(s => s.LiebUserId == userId && s.SignUpType == SignUpType.Flex))
|
||||||
{
|
{
|
||||||
if (!checkedRoleIds.Contains(signUp.RaidRoleId)
|
if (!checkedRoleIds.Contains(signUp.RaidRoleId)
|
||||||
&& await IsRoleSignUpAllowed(raid, userId, signUp.RaidRoleId, SignUpType.SignedUp, moveFlexUser, checkedRoleIds))
|
&& await IsRoleSignUpAllowedMoveFlex(raid, userId, signUp.RaidRoleId, SignUpType.SignedUp, moveFlexUser, checkedRoleIds))
|
||||||
{
|
{
|
||||||
if (moveFlexUser)
|
if (moveFlexUser)
|
||||||
{
|
{
|
||||||
await ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp, false);
|
await ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp, raid.RaidType, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -348,6 +385,33 @@ namespace Lieb.Data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsRandomRoleSignUpAllowed(Raid raid, ulong liebUserId, SignUpType signUpType, int plannedRoleId = 0)
|
||||||
|
{
|
||||||
|
RaidRole randomRole = raid.Roles.First(r => r.IsRandomSignUpRole);
|
||||||
|
int signedUpUsers = raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
||||||
|
int randomSpots = randomRole.Spots;
|
||||||
|
|
||||||
|
if(raid.SignUps.Where(s => s.LiebUserId == liebUserId).Any())
|
||||||
|
{
|
||||||
|
int userRoleId = raid.SignUps.First(s => s.LiebUserId == liebUserId).RaidRoleId;
|
||||||
|
if(plannedRoleId != 0 && plannedRoleId != userRoleId) return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(plannedRoleId != 0 && plannedRoleId != randomRole.RaidRoleId) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(randomSpots - signedUpUsers > 0) return true;
|
||||||
|
|
||||||
|
if(signUpType == SignUpType.Backup) return true;
|
||||||
|
|
||||||
|
if(raid.SignUps.Where(s => s.LiebUserId == liebUserId).Any())
|
||||||
|
{
|
||||||
|
return raid.SignUps.First(s => s.LiebUserId == liebUserId).SignUpType == SignUpType.SignedUp;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsRaidSignUpAllowed(ulong liebUserId, int raidId, out string errorMessage, bool ignoreRole = false)
|
public bool IsRaidSignUpAllowed(ulong liebUserId, int raidId, out string errorMessage, bool ignoreRole = false)
|
||||||
{
|
{
|
||||||
errorMessage = string.Empty;
|
errorMessage = string.Empty;
|
||||||
|
@ -365,6 +429,7 @@ namespace Lieb.Data
|
||||||
.ThenInclude(a => a.LiebRole)
|
.ThenInclude(a => a.LiebRole)
|
||||||
.Include(u => u.GuildWars2Accounts)
|
.Include(u => u.GuildWars2Accounts)
|
||||||
.ThenInclude(a => a.EquippedBuilds)
|
.ThenInclude(a => a.EquippedBuilds)
|
||||||
|
.ThenInclude(b => b.GuildWars2Build)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.FirstOrDefault(r => r.Id == liebUserId);
|
.FirstOrDefault(r => r.Id == liebUserId);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
|
@ -379,7 +444,7 @@ namespace Lieb.Data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raid.RaidType != RaidType.Planned && !user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).Any())
|
if (raid.RaidType != RaidType.Planned && !user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Where(b => b.GuildWars2Build.UseInRandomRaid).Count() > 0).Any())
|
||||||
{
|
{
|
||||||
errorMessage = "No equipped Guild Wars 2 build found.";
|
errorMessage = "No equipped Guild Wars 2 build found.";
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace Lieb.Data
|
||||||
return context.LiebUsers
|
return context.LiebUsers
|
||||||
.Include(u => u.GuildWars2Accounts)
|
.Include(u => u.GuildWars2Accounts)
|
||||||
.ThenInclude(a => a.EquippedBuilds)
|
.ThenInclude(a => a.EquippedBuilds)
|
||||||
|
.ThenInclude(b => b.GuildWars2Build)
|
||||||
.FirstOrDefault(u => u.Id == userId);
|
.FirstOrDefault(u => u.Id == userId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -281,7 +282,7 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
return user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Where(b => b.GuildWars2Build.UseInRandomRaid).Count() > 0).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,10 @@
|
||||||
}
|
}
|
||||||
@foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.RaidRoleId))
|
@foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.RaidRoleId))
|
||||||
{
|
{
|
||||||
<tr>
|
//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();
|
||||||
|
<tr hidden="@roleHidden">
|
||||||
@{
|
@{
|
||||||
<td class="tdRole" @onclick="() => ToggleRow(role)">
|
<td class="tdRole" @onclick="() => ToggleRow(role)">
|
||||||
@if(@role.IsRowExpanded)
|
@if(@role.IsRowExpanded)
|
||||||
|
@ -135,7 +138,7 @@
|
||||||
{
|
{
|
||||||
if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
|
if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
|
||||||
{
|
{
|
||||||
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType);
|
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType, _raid.RaidType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace SharedClasses.SharedModels
|
||||||
|
|
||||||
public int RaidId { get; set; }
|
public int RaidId { get; set; }
|
||||||
|
|
||||||
|
public bool AllowFlexRole {get; set;}
|
||||||
|
|
||||||
public DateTimeOffset StartTimeUTC { get; set; } = DateTime.Now;
|
public DateTimeOffset StartTimeUTC { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public DateTimeOffset EndTimeUTC { get; set; }
|
public DateTimeOffset EndTimeUTC { get; set; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue