From 2dfcf13f79b728e383d2a786fc34becb479bb58d Mon Sep 17 00:00:00 2001 From: "t.ruspekhofer" Date: Thu, 17 Mar 2022 14:46:30 +0100 Subject: [PATCH] fixed a bug with moving Flex users. async was seemingly not allowed --- Lieb/Data/DbInitializer.cs | 28 ++++++++++++++++++++++++---- Lieb/Data/RaidService.cs | 9 ++++----- Lieb/Pages/Raids/RaidDetails.razor | 6 ++++-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Lieb/Data/DbInitializer.cs b/Lieb/Data/DbInitializer.cs index 98a1f8a..44d3250 100644 --- a/Lieb/Data/DbInitializer.cs +++ b/Lieb/Data/DbInitializer.cs @@ -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); diff --git a/Lieb/Data/RaidService.cs b/Lieb/Data/RaidService.cs index e84ba7f..c8bed68 100644 --- a/Lieb/Data/RaidService.cs +++ b/Lieb/Data/RaidService.cs @@ -194,7 +194,7 @@ namespace Lieb.Data List 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; } diff --git a/Lieb/Pages/Raids/RaidDetails.razor b/Lieb/Pages/Raids/RaidDetails.razor index 1438d9a..33a66ee 100644 --- a/Lieb/Pages/Raids/RaidDetails.razor +++ b/Lieb/Pages/Raids/RaidDetails.razor @@ -44,10 +44,12 @@ - +
- + + + @if(_raid.RaidType != RaidType.Planned)