fixed a bug with moving Flex users.

async was seemingly not allowed
This commit is contained in:
t.ruspekhofer 2022-03-17 14:46:30 +01:00
parent cace18e3d6
commit 2dfcf13f79
3 changed files with 32 additions and 11 deletions

View file

@ -96,6 +96,24 @@ namespace Lieb.Data
Description = RaidType.RandomWithBoons.ToString(),
IsRandomSignUpRole = true
};
PlannedRaidRole flexTest1 = new PlannedRaidRole()
{
Description = "flexTest1",
Name = "flexTest1",
Spots = 1
};
PlannedRaidRole flexTest2 = new PlannedRaidRole()
{
Description = "flexTest2",
Name = "flexTest2",
Spots = 1
};
PlannedRaidRole flexTest3 = new PlannedRaidRole()
{
Description = "flexTest3",
Name = "flexTest3",
Spots = 1
};
Raid raid = new Raid()
{
@ -103,12 +121,12 @@ namespace Lieb.Data
Description = "This is a test raid\nwith multiple lines?",
Guild = "LIEB",
Organizer = "Sarah",
RaidType = RaidType.RandomWithBoons,
RaidType = RaidType.Planned,
StartTimeUTC = DateTime.UtcNow,
EndTimeUTC = DateTime.UtcNow.AddHours(2),
FreeForAllTimeUTC = DateTime.UtcNow.AddHours(-2),
VoiceChat = "ts.lieb.games",
Roles = new [] { randomRole, ele, scourge}
Roles = new [] { randomRole, ele, scourge, flexTest1, flexTest2, flexTest3 }
};
context.Raids.Add(raid);
context.SaveChanges();
@ -141,8 +159,10 @@ namespace Lieb.Data
var signUps = new RaidSignUp[]
{
new RaidSignUp{GuildWars2AccountId = linaith.GuildWars2AccountId, LiebUserId = users[0].LiebUserId, PlannedRaidRoleId = ele.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, PlannedRaidRoleId = scourge.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, PlannedRaidRoleId = scourge.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Maybe }
new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, PlannedRaidRoleId = flexTest1.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, PlannedRaidRoleId = flexTest2.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, PlannedRaidRoleId = flexTest2.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Flex },
new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, PlannedRaidRoleId = flexTest3.PlannedRaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Flex }
};
context.RaidSignUps.AddRange(signUps);

View file

@ -194,7 +194,7 @@ namespace Lieb.Data
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())
{
await ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType);
ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType);
}
else if (!signUps.Where(r => r.PlannedRaidRoleId == plannedRoleId).Any())
{
@ -246,7 +246,7 @@ namespace Lieb.Data
await context.SaveChangesAsync();
}
public async Task ChangeSignUpType(int raidId, int liebUserId, int plannedRoleId, SignUpType signUpType)
public void ChangeSignUpType(int raidId, int liebUserId, int plannedRoleId, SignUpType signUpType)
{
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
{
@ -264,7 +264,6 @@ namespace Lieb.Data
if (flexSignUp != null && signUp != null)
{
flexSignUp.PlannedRaidRoleId = signUp.PlannedRaidRoleId;
await context.SaveChangesAsync();
}
//change to new role
@ -272,8 +271,8 @@ namespace Lieb.Data
{
signUp.PlannedRaidRoleId = plannedRoleId;
signUp.SignUpType = signUpType;
await context.SaveChangesAsync();
}
context.SaveChanges();
}
public bool IsRoleSignUpAllowed(int liebUserId, int plannedRoleId, SignUpType signUpType)
@ -360,7 +359,7 @@ namespace Lieb.Data
{
if (moveFlexUser)
{
await ChangeSignUpType(raid.RaidId, userId, signUp.PlannedRaidRoleId, SignUpType.SignedUp);
ChangeSignUpType(raid.RaidId, userId, signUp.PlannedRaidRoleId, SignUpType.SignedUp);
}
return true;
}

View file

@ -44,10 +44,12 @@
</span>
<RaidRoles _raid=@_raid _user=@_user/>
<RaidRoles _raid=@_raid _user=@_user _isRaidSignUpAllowed=@_isRaidSignUpAllowed/>
<div>
<AuthorizeView>
<button class="controlButton" @onclick="() => SignOffClicked()">Sign Off</button>
</AuthorizeView>
<AuthorizeView Policy="@Constants.Roles.RaidLead">
<button class="controlButton" @onclick="() => EditClicked()">Edit</button>
@if(_raid.RaidType != RaidType.Planned)