Renamed PlannedRaidRole to RaidRole

This commit is contained in:
t.ruspekhofer 2022-04-06 23:20:29 +02:00
parent 7533d5a704
commit dcdc891925
17 changed files with 65 additions and 46 deletions

View file

@ -158,11 +158,11 @@ namespace Lieb.Data
var signUps = new RaidSignUp[] var signUps = new RaidSignUp[]
{ {
new RaidSignUp{GuildWars2AccountId = linaith.GuildWars2AccountId, LiebUserId = users[0].LiebUserId, PlannedRaidRoleId = ele.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp }, new RaidSignUp{GuildWars2AccountId = linaith.GuildWars2AccountId, LiebUserId = users[0].LiebUserId, RaidRoleId = ele.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, PlannedRaidRoleId = flexTest1.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp }, new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, RaidRoleId = flexTest1.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, PlannedRaidRoleId = flexTest2.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp }, new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, RaidRoleId = flexTest2.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.SignedUp },
new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, PlannedRaidRoleId = flexTest2.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Flex }, new RaidSignUp{GuildWars2AccountId = hierpiepts.GuildWars2AccountId, LiebUserId = users[1].LiebUserId, RaidRoleId = flexTest2.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Flex },
new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, PlannedRaidRoleId = flexTest3.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Flex } new RaidSignUp{GuildWars2AccountId = bloodseeker.GuildWars2AccountId, LiebUserId = users[2].LiebUserId, RaidRoleId = flexTest3.RaidRoleId, RaidId = raid.RaidId, SignUpType = SignUpType.Flex }
}; };
context.RaidSignUps.AddRange(signUps); context.RaidSignUps.AddRange(signUps);

View file

@ -25,6 +25,7 @@ namespace Lieb.Data
public DbSet<RaidReminder> RaidReminders { get; set; } public DbSet<RaidReminder> RaidReminders { get; set; }
public DbSet<RaidSignUp> RaidSignUps { get; set; } public DbSet<RaidSignUp> RaidSignUps { get; set; }
public DbSet<RaidSignUpHistory> RaidSignUpHistories { get; set; } public DbSet<RaidSignUpHistory> RaidSignUpHistories { get; set; }
public DbSet<DiscordRaidMessage> DiscordRaidMessages { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
@ -41,6 +42,7 @@ namespace Lieb.Data
modelBuilder.Entity<RaidReminder>().ToTable("RaidReminder"); modelBuilder.Entity<RaidReminder>().ToTable("RaidReminder");
modelBuilder.Entity<RaidSignUp>().ToTable("RaidSignUp"); modelBuilder.Entity<RaidSignUp>().ToTable("RaidSignUp");
modelBuilder.Entity<RaidSignUpHistory>().ToTable("RaidSignUpHistory"); modelBuilder.Entity<RaidSignUpHistory>().ToTable("RaidSignUpHistory");
modelBuilder.Entity<DiscordRaidMessage>().ToTable("DiscordRaidMessage");
} }
} }
} }

View file

@ -28,7 +28,7 @@ namespace Lieb.Data
.ThenInclude(a => a.EquippedBuilds) .ThenInclude(a => a.EquippedBuilds)
.ThenInclude(e => e.GuildWars2Build) .ThenInclude(e => e.GuildWars2Build)
.Include(r => r.SignUps) .Include(r => r.SignUps)
.ThenInclude(s => s.PlannedRaidRole) .ThenInclude(s => s.RaidRole)
.FirstOrDefault(r => r.RaidId == raidId); .FirstOrDefault(r => r.RaidId == raidId);
if (raid == null || raid.RaidType == RaidType.Planned) if (raid == null || raid.RaidType == RaidType.Planned)
@ -71,7 +71,7 @@ namespace Lieb.Data
role.Name = "No class found."; role.Name = "No class found.";
} }
raid.Roles.Add(role); raid.Roles.Add(role);
signUp.PlannedRaidRole = role; signUp.RaidRole = role;
} }
} }
@ -95,7 +95,7 @@ namespace Lieb.Data
role.Name = "No class found."; role.Name = "No class found.";
} }
raid.Roles.Add(role); raid.Roles.Add(role);
signUp.PlannedRaidRole = role; signUp.RaidRole = role;
} }
} }
@ -117,7 +117,7 @@ namespace Lieb.Data
role.Name = userBuild.Value.BuildName; role.Name = userBuild.Value.BuildName;
raid.Roles.Add(role); raid.Roles.Add(role);
RaidSignUp signUp = raid.SignUps.FirstOrDefault(s => s.LiebUserId == userBuild.Key); RaidSignUp signUp = raid.SignUps.FirstOrDefault(s => s.LiebUserId == userBuild.Key);
signUp.PlannedRaidRole = role; signUp.RaidRole = role;
} }
} }
@ -329,7 +329,7 @@ namespace Lieb.Data
List<RaidRole> rolesToDelete = new List<RaidRole>(); List<RaidRole> rolesToDelete = new List<RaidRole>();
foreach (RaidRole role in raid.Roles) foreach (RaidRole role in raid.Roles)
{ {
if (!role.IsRandomSignUpRole && raid.SignUps.FirstOrDefault(s => s.PlannedRaidRoleId == role.RaidRoleId) == null) if (!role.IsRandomSignUpRole && raid.SignUps.FirstOrDefault(s => s.RaidRoleId == role.RaidRoleId) == null)
{ {
rolesToDelete.Add(role); rolesToDelete.Add(role);
} }

View file

@ -25,7 +25,7 @@ namespace Lieb.Data
.Include(r => r.SignUps) .Include(r => r.SignUps)
.ThenInclude(s => s.GuildWars2Account) .ThenInclude(s => s.GuildWars2Account)
.Include(r => r.SignUps) .Include(r => r.SignUps)
.ThenInclude(s => s.PlannedRaidRole) .ThenInclude(s => s.RaidRole)
.ToList(); .ToList();
} }
@ -41,7 +41,7 @@ namespace Lieb.Data
.Include(r => r.SignUps) .Include(r => r.SignUps)
.ThenInclude(s => s.GuildWars2Account) .ThenInclude(s => s.GuildWars2Account)
.Include(r => r.SignUps) .Include(r => r.SignUps)
.ThenInclude(s => s.PlannedRaidRole) .ThenInclude(s => s.RaidRole)
.FirstOrDefault(r => r.RaidId == raidId); .FirstOrDefault(r => r.RaidId == raidId);
} }
@ -67,7 +67,7 @@ namespace Lieb.Data
RaidRole randomRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole); RaidRole randomRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole);
foreach (RaidSignUp signUp in raid.SignUps) foreach (RaidSignUp signUp in raid.SignUps)
{ {
signUp.PlannedRaidRole = randomRole; signUp.RaidRole = randomRole;
} }
context.RaidRoles.RemoveRange(raid.Roles.Where(r => !r.IsRandomSignUpRole)); context.RaidRoles.RemoveRange(raid.Roles.Where(r => !r.IsRandomSignUpRole));
} }
@ -103,14 +103,14 @@ namespace Lieb.Data
{ {
ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType); ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType);
} }
else if (!signUps.Where(r => r.PlannedRaidRoleId == plannedRoleId).Any()) else if (!signUps.Where(r => r.RaidRoleId == plannedRoleId).Any())
{ {
context.RaidSignUps.Add(new RaidSignUp() context.RaidSignUps.Add(new RaidSignUp()
{ {
GuildWars2AccountId = guildWars2AccountId, GuildWars2AccountId = guildWars2AccountId,
RaidId = raidId, RaidId = raidId,
LiebUserId = liebUserId, LiebUserId = liebUserId,
PlannedRaidRoleId = plannedRoleId, RaidRoleId = plannedRoleId,
SignUpType = signUpType SignUpType = signUpType
}); });
await context.SaveChangesAsync(); await context.SaveChangesAsync();
@ -132,10 +132,10 @@ namespace Lieb.Data
//change and delete Role for Random Raids //change and delete Role for Random Raids
Raid? raid = context.Raids.Include(r => r.Roles).FirstOrDefault(r => r.RaidId == raidId); Raid? raid = context.Raids.Include(r => r.Roles).FirstOrDefault(r => r.RaidId == raidId);
if(raid != null && raid.RaidType != RaidType.Planned && !signUp.PlannedRaidRole.IsRandomSignUpRole) if(raid != null && raid.RaidType != RaidType.Planned && !signUp.RaidRole.IsRandomSignUpRole)
{ {
context.RaidRoles.Remove(signUp.PlannedRaidRole); context.RaidRoles.Remove(signUp.RaidRole);
signUp.PlannedRaidRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole); signUp.RaidRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole);
} }
} }
@ -165,18 +165,18 @@ namespace Lieb.Data
List<RaidSignUp> signUps = context.RaidSignUps.Where(x => x.RaidId == raidId && x.LiebUserId == liebUserId).ToList(); List<RaidSignUp> signUps = context.RaidSignUps.Where(x => x.RaidId == raidId && x.LiebUserId == liebUserId).ToList();
RaidSignUp? signUp = signUps.FirstOrDefault(x => x.SignUpType != SignUpType.Flex); RaidSignUp? signUp = signUps.FirstOrDefault(x => x.SignUpType != SignUpType.Flex);
RaidSignUp? flexSignUp = signUps.FirstOrDefault(x => x.SignUpType == SignUpType.Flex && x.PlannedRaidRoleId == plannedRoleId); RaidSignUp? flexSignUp = signUps.FirstOrDefault(x => x.SignUpType == SignUpType.Flex && x.RaidRoleId == plannedRoleId);
//change Flex to current role //change Flex to current role
if (flexSignUp != null && signUp != null) if (flexSignUp != null && signUp != null)
{ {
flexSignUp.PlannedRaidRoleId = signUp.PlannedRaidRoleId; flexSignUp.RaidRoleId = signUp.RaidRoleId;
} }
//change to new role //change to new role
if (signUp != null) if (signUp != null)
{ {
signUp.PlannedRaidRoleId = plannedRoleId; signUp.RaidRoleId = plannedRoleId;
signUp.SignUpType = signUpType; signUp.SignUpType = signUpType;
} }
context.SaveChanges(); context.SaveChanges();
@ -191,7 +191,7 @@ namespace Lieb.Data
using var context = _contextFactory.CreateDbContext(); using var context = _contextFactory.CreateDbContext();
List<RaidSignUp> signUps = context.RaidSignUps.Where(s => s.PlannedRaidRoleId == plannedRoleId).ToList(); List<RaidSignUp> signUps = context.RaidSignUps.Where(s => s.RaidRoleId == plannedRoleId).ToList();
RaidRole? role = context.RaidRoles RaidRole? role = context.RaidRoles
.FirstOrDefault(r => r.RaidRoleId == plannedRoleId); .FirstOrDefault(r => r.RaidRoleId == plannedRoleId);
@ -237,9 +237,9 @@ namespace Lieb.Data
// new sign up is available if there are free spots and the user is not signed up or still in the random role // 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); RaidSignUp? signUp = raid.SignUps.FirstOrDefault(s => s.LiebUserId == liebUserId);
return raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < role.Spots return raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < role.Spots
&& (signUp == null || signUp.PlannedRaidRoleId == plannedRoleId || signUp.SignUpType == SignUpType.SignedOff); && (signUp == null || signUp.RaidRoleId == plannedRoleId || signUp.SignUpType == SignUpType.SignedOff);
} }
return raid.SignUps.Where(s => s.LiebUserId == liebUserId && s.PlannedRaidRoleId == plannedRoleId).Any(); return raid.SignUps.Where(s => s.LiebUserId == liebUserId && s.RaidRoleId == plannedRoleId).Any();
} }
} }
@ -257,16 +257,16 @@ namespace Lieb.Data
return false; return false;
} }
foreach (int userId in raid.SignUps.Where(s => s.PlannedRaidRoleId == plannedRoleId && s.SignUpType == SignUpType.SignedUp).Select(s => s.LiebUserId)) foreach (int userId in raid.SignUps.Where(s => s.RaidRoleId == plannedRoleId && s.SignUpType == SignUpType.SignedUp).Select(s => s.LiebUserId))
{ {
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.PlannedRaidRoleId) if (!checkedRoleIds.Contains(signUp.RaidRoleId)
&& await IsRoleSignUpAllowed(raid, userId, signUp.PlannedRaidRoleId, SignUpType.SignedUp, moveFlexUser, checkedRoleIds)) && await IsRoleSignUpAllowed(raid, userId, signUp.RaidRoleId, SignUpType.SignedUp, moveFlexUser, checkedRoleIds))
{ {
if (moveFlexUser) if (moveFlexUser)
{ {
ChangeSignUpType(raid.RaidId, userId, signUp.PlannedRaidRoleId, SignUpType.SignedUp); ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp);
} }
return true; return true;
} }

View file

@ -128,7 +128,7 @@
</tr> </tr>
@foreach( RaidRole role in _raid.Roles) @foreach( RaidRole role in _raid.Roles)
{ {
bool disableEdit = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.RaidRoleId).Any(); bool disableEdit = _raid.SignUps.Where(s => s.RaidRoleId == role.RaidRoleId).Any();
<tr> <tr>
<td><InputNumber @bind-Value="role.Spots" disabled="@disableEdit" /></td> <td><InputNumber @bind-Value="role.Spots" disabled="@disableEdit" /></td>
<td><InputText @bind-Value="role.Name" disabled="@disableEdit" /></td> <td><InputText @bind-Value="role.Name" disabled="@disableEdit" /></td>

View file

@ -21,7 +21,7 @@
<br /> <br />
<label> <label>
Filter From: From:
<input type="date" value="@_startDate.ToString("yyyy-MM-dd")" @onchange="args => StartFilterChanged(args)" /> <input type="date" value="@_startDate.ToString("yyyy-MM-dd")" @onchange="args => StartFilterChanged(args)" />
To: To:
<input type="date" value="@_endDate.ToString("yyyy-MM-dd")" @onchange="args => EndFilterChanged(args)" /> <input type="date" value="@_endDate.ToString("yyyy-MM-dd")" @onchange="args => EndFilterChanged(args)" />
@ -73,13 +73,23 @@
private void StartFilterChanged(ChangeEventArgs e) private void StartFilterChanged(ChangeEventArgs e)
{ {
_startDate = DateTime.Parse(e.Value.ToString()); if(!DateTime.TryParse(e.Value.ToString(), out _startDate))
{
_startDate = DateTime.UnixEpoch;
}
ApplyFilter(); ApplyFilter();
} }
private void EndFilterChanged(ChangeEventArgs e) private void EndFilterChanged(ChangeEventArgs e)
{ {
_endDate = DateTime.Parse(e.Value.ToString()).AddDays(1).AddSeconds(-1); if(DateTime.TryParse(e.Value.ToString(), out _endDate))
{
_endDate.AddDays(1).AddSeconds(-1);
}
else
{
_endDate = DateTime.MaxValue.Date;
}
ApplyFilter(); ApplyFilter();
} }

View file

@ -0,0 +1,7 @@
body {
}
input {
margin-right: 20px;
width: fit-content;
}

View file

@ -46,7 +46,7 @@
{ {
<span class="oi oi-chevron-bottom" style="margin-right:7px"> </span> <span class="oi oi-chevron-bottom" style="margin-right:7px"> </span>
} }
<b>@role.Role.Name</b> (@_raid.SignUps.Where(s => s.PlannedRaidRoleId == role.Role.RaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Role.Spots) <b>@role.Role.Name</b> (@_raid.SignUps.Where(s => s.RaidRoleId == role.Role.RaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Role.Spots)
@if (@role.IsRowExpanded) @if (@role.IsRowExpanded)
{ {
<br> @role.Role.Description <br> @role.Role.Description

View file

@ -6,7 +6,7 @@
<table> <table>
@{RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == _currentRoleId).ToArray();} @{RaidSignUp[] signUps = _raid.SignUps.Where(s => s.RaidRoleId == _currentRoleId).ToArray();}
@foreach (var signUp in signUps.OrderBy(s => s.SignUpType)) @foreach (var signUp in signUps.OrderBy(s => s.SignUpType))
{ {
@if(_signUpTypes.Contains(signUp.SignUpType)) @if(_signUpTypes.Contains(signUp.SignUpType))

View file

@ -16,13 +16,13 @@
public int RaidId { get; set; } public int RaidId { get; set; }
public int LiebUserId { get; set; } public int LiebUserId { get; set; }
public int GuildWars2AccountId { get; set; } public int GuildWars2AccountId { get; set; }
public int PlannedRaidRoleId { get; set; } public int RaidRoleId { get; set; }
public SignUpType SignUpType { get; set; } public SignUpType SignUpType { get; set; }
public Raid Raid { get; set; } public Raid Raid { get; set; }
public LiebUser LiebUser { get; set; } public LiebUser LiebUser { get; set; }
public GuildWars2Account GuildWars2Account { get; set; } public GuildWars2Account GuildWars2Account { get; set; }
public RaidRole PlannedRaidRole { get; set; } public RaidRole RaidRole { get; set; }
} }
} }