added support for External users
fixed potential errors
This commit is contained in:
parent
a47bc3207d
commit
62dc3d1efa
10 changed files with 257 additions and 130 deletions
|
@ -40,8 +40,8 @@ namespace Lieb.Data
|
||||||
GuildWars2Account bloodseeker = new GuildWars2Account() { AccountName = "Bloodseeker.2043" };
|
GuildWars2Account bloodseeker = new GuildWars2Account() { AccountName = "Bloodseeker.2043" };
|
||||||
var users = new LiebUser[]
|
var users = new LiebUser[]
|
||||||
{
|
{
|
||||||
new LiebUser{Id=0, Name="Sarah", Birthday=DateTime.Parse("1992-01-15"), GuildWars2Accounts = new List<GuildWars2Account>(){ linaith, sarah} },
|
//new LiebUser{Id=0, Name="Sarah", Birthday=DateTime.Parse("1992-01-15"), GuildWars2Accounts = new List<GuildWars2Account>(){ linaith, sarah} },
|
||||||
//new LiebUser{Id=194863625477816321, Name="Sarah", Birthday=DateTime.Parse("1992-01-15"), GuildWars2Accounts = new List<GuildWars2Account>(){ linaith, sarah} },
|
new LiebUser{Id=194863625477816321, Name="Sarah", Birthday=DateTime.Parse("1992-01-15"), GuildWars2Accounts = new List<GuildWars2Account>(){ linaith, sarah} },
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
new LiebUser{Id=194455125769715713, Name="Lisa", GuildWars2Accounts = new List<GuildWars2Account>(){ hierpiepts}},
|
new LiebUser{Id=194455125769715713, Name="Lisa", GuildWars2Accounts = new List<GuildWars2Account>(){ hierpiepts}},
|
||||||
new LiebUser{Id=2, Name="Simon", GuildWars2Accounts = new List<GuildWars2Account>(){ bloodseeker}}
|
new LiebUser{Id=2, Name="Simon", GuildWars2Accounts = new List<GuildWars2Account>(){ bloodseeker}}
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PostRaidMessage(int raidId)
|
public async Task PostRaidMessage(int raidId)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
Raid raid = context.Raids
|
Raid raid = context.Raids
|
||||||
|
@ -36,12 +38,9 @@ namespace Lieb.Data
|
||||||
.Include(r => r.SignUps)
|
.Include(r => r.SignUps)
|
||||||
.ThenInclude(s => s.RaidRole)
|
.ThenInclude(s => s.RaidRole)
|
||||||
.Include(r => r.DiscordRaidMessages)
|
.Include(r => r.DiscordRaidMessages)
|
||||||
.FirstOrDefault(r => r.RaidId == raidId);
|
.ToList()
|
||||||
await PostRaidMessage(raid);
|
.FirstOrDefault(r => r.RaidId == raidId, new Raid());
|
||||||
}
|
|
||||||
|
|
||||||
public async Task PostRaidMessage(Raid raid)
|
|
||||||
{
|
|
||||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||||
|
|
||||||
ApiRaid apiRaid = ConvertRaid(raid);
|
ApiRaid apiRaid = ConvertRaid(raid);
|
||||||
|
@ -64,6 +63,8 @@ namespace Lieb.Data
|
||||||
await UpdateDiscordMessages(returnedRaid.DisocrdMessages, raid);
|
await UpdateDiscordMessages(returnedRaid.DisocrdMessages, raid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch {}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task DeleteRaidMessages(Raid raid)
|
public async Task DeleteRaidMessages(Raid raid)
|
||||||
{
|
{
|
||||||
|
@ -71,6 +72,8 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteRaidMessages(IEnumerable<DiscordRaidMessage> messages)
|
public async Task DeleteRaidMessages(IEnumerable<DiscordRaidMessage> messages)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||||
|
|
||||||
|
@ -85,6 +88,8 @@ namespace Lieb.Data
|
||||||
|
|
||||||
httpResponseMessage.EnsureSuccessStatusCode();
|
httpResponseMessage.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
catch {}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<DiscordServer>> GetServers()
|
public async Task<List<DiscordServer>> GetServers()
|
||||||
{
|
{
|
||||||
|
@ -102,14 +107,13 @@ namespace Lieb.Data
|
||||||
return await JsonSerializer.DeserializeAsync<List<DiscordServer>>(contentStream, _serializerOptions);
|
return await JsonSerializer.DeserializeAsync<List<DiscordServer>>(contentStream, _serializerOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return new List<DiscordServer>();
|
return new List<DiscordServer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendUserReminder(RaidReminder reminder)
|
public async Task SendUserReminder(RaidReminder reminder)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||||
|
@ -137,8 +141,12 @@ namespace Lieb.Data
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch {}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task SendChannelReminder(RaidReminder reminder)
|
public async Task SendChannelReminder(RaidReminder reminder)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||||
|
|
||||||
|
@ -159,6 +167,8 @@ namespace Lieb.Data
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch {}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateDiscordMessages(IEnumerable<ApiRaid.DiscordMessage> messages, Raid raid)
|
private async Task UpdateDiscordMessages(IEnumerable<ApiRaid.DiscordMessage> messages, Raid raid)
|
||||||
{
|
{
|
||||||
|
@ -205,6 +215,17 @@ namespace Lieb.Data
|
||||||
foreach(RaidSignUp signUp in raid.SignUps.Where(x => x.RaidRoleId == role.RaidRoleId))
|
foreach(RaidSignUp signUp in raid.SignUps.Where(x => x.RaidRoleId == role.RaidRoleId))
|
||||||
{
|
{
|
||||||
if(signUp.SignUpType != SignUpType.SignedOff)
|
if(signUp.SignUpType != SignUpType.SignedOff)
|
||||||
|
{
|
||||||
|
if(signUp.IsExternalUser)
|
||||||
|
{
|
||||||
|
string status = signUp.SignUpType != SignUpType.SignedUp ? signUp.SignUpType.ToString() : string.Empty;
|
||||||
|
apiRole.Users.Add(new ApiRaid.Role.User(){
|
||||||
|
AccountName = string.Empty,
|
||||||
|
Status = status,
|
||||||
|
UserName = signUp.ExternalUserName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
string status = signUp.SignUpType != SignUpType.SignedUp ? signUp.SignUpType.ToString() : string.Empty;
|
string status = signUp.SignUpType != SignUpType.SignedUp ? signUp.SignUpType.ToString() : string.Empty;
|
||||||
apiRole.Users.Add(new ApiRaid.Role.User(){
|
apiRole.Users.Add(new ApiRaid.Role.User(){
|
||||||
|
@ -214,6 +235,7 @@ namespace Lieb.Data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
apiRaid.Roles.Add(apiRole);
|
apiRaid.Roles.Add(apiRole);
|
||||||
}
|
}
|
||||||
return apiRaid;
|
return apiRaid;
|
||||||
|
|
|
@ -46,7 +46,8 @@ namespace Lieb.Data
|
||||||
.Include(r => r.SignUps)
|
.Include(r => r.SignUps)
|
||||||
.ThenInclude(s => s.RaidRole)
|
.ThenInclude(s => s.RaidRole)
|
||||||
.Include(r => r.DiscordRaidMessages)
|
.Include(r => r.DiscordRaidMessages)
|
||||||
.FirstOrDefault(r => r.RaidId == raidId);
|
.ToList()
|
||||||
|
.FirstOrDefault(r => r.RaidId == raidId, new Raid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddOrEditRaid(Raid raid, List<RaidRole> rolesToDelete, List<RaidReminder> remindersToDelete, List<DiscordRaidMessage> messagesToDelete)
|
public async Task AddOrEditRaid(Raid raid, List<RaidRole> rolesToDelete, List<RaidReminder> remindersToDelete, List<DiscordRaidMessage> messagesToDelete)
|
||||||
|
@ -69,7 +70,7 @@ namespace Lieb.Data
|
||||||
//move users back to "Random" role
|
//move users back to "Random" role
|
||||||
if (raid.RaidType != RaidType.Planned)
|
if (raid.RaidType != RaidType.Planned)
|
||||||
{
|
{
|
||||||
RaidRole randomRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole);
|
RaidRole randomRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole, CreateRandomSignUpRole(raid.RaidType));
|
||||||
foreach (RaidSignUp signUp in raid.SignUps)
|
foreach (RaidSignUp signUp in raid.SignUps)
|
||||||
{
|
{
|
||||||
signUp.RaidRole = randomRole;
|
signUp.RaidRole = randomRole;
|
||||||
|
@ -79,7 +80,7 @@ namespace Lieb.Data
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
_discordService.PostRaidMessage(raid.RaidId);
|
await _discordService.PostRaidMessage(raid.RaidId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ namespace Lieb.Data
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
context.Raids.Remove(raid);
|
context.Raids.Remove(raid);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
_discordService.DeleteRaidMessages(raid);
|
await _discordService.DeleteRaidMessages(raid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SignUp(int raidId, ulong liebUserId, int guildWars2AccountId, int plannedRoleId, SignUpType signUpType)
|
public async Task SignUp(int raidId, ulong liebUserId, int guildWars2AccountId, int plannedRoleId, SignUpType signUpType)
|
||||||
|
@ -108,24 +109,48 @@ 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())
|
||||||
{
|
{
|
||||||
ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType);
|
await ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType);
|
||||||
}
|
}
|
||||||
else if (!signUps.Where(r => r.RaidRoleId == plannedRoleId).Any())
|
else if (!signUps.Where(r => r.RaidRoleId == plannedRoleId).Any())
|
||||||
{
|
{
|
||||||
context.RaidSignUps.Add(new RaidSignUp()
|
RaidSignUp signUp = new RaidSignUp()
|
||||||
{
|
{
|
||||||
GuildWars2AccountId = guildWars2AccountId,
|
GuildWars2AccountId = guildWars2AccountId,
|
||||||
RaidId = raidId,
|
RaidId = raidId,
|
||||||
LiebUserId = liebUserId,
|
LiebUserId = liebUserId,
|
||||||
RaidRoleId = plannedRoleId,
|
RaidRoleId = plannedRoleId,
|
||||||
SignUpType = signUpType
|
SignUpType = signUpType
|
||||||
});
|
};
|
||||||
|
context.RaidSignUps.Add(signUp);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
await LogSignUp(signUp);
|
||||||
}
|
}
|
||||||
_discordService.PostRaidMessage(raidId);
|
await _discordService.PostRaidMessage(raidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SignOff(int raidId, ulong liebUserId)
|
public async Task SignUpExternalUser(int raidId, string userName, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId)
|
||||||
|
{
|
||||||
|
if (!IsRoleSignUpAllowed(raidId, ulong.MaxValue, plannedRoleId, signUpType, true))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
|
||||||
|
|
||||||
|
RaidSignUp signUp = new RaidSignUp()
|
||||||
|
{
|
||||||
|
RaidId = raidId,
|
||||||
|
ExternalUserName = userName,
|
||||||
|
RaidRoleId = plannedRoleId,
|
||||||
|
SignUpType = signUpType
|
||||||
|
};
|
||||||
|
context.RaidSignUps.Add(signUp);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
await LogSignUp(signUp, signedUpByUserId);
|
||||||
|
await _discordService.PostRaidMessage(raidId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SignOff(int raidId, ulong liebUserId, ulong signedOffByUserId = 0)
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
//remove Flex Sign Ups
|
//remove Flex Sign Ups
|
||||||
|
@ -143,11 +168,29 @@ namespace Lieb.Data
|
||||||
if(raid != null && raid.RaidType != RaidType.Planned && !signUp.RaidRole.IsRandomSignUpRole)
|
if(raid != null && raid.RaidType != RaidType.Planned && !signUp.RaidRole.IsRandomSignUpRole)
|
||||||
{
|
{
|
||||||
context.RaidRoles.Remove(signUp.RaidRole);
|
context.RaidRoles.Remove(signUp.RaidRole);
|
||||||
signUp.RaidRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole);
|
signUp.RaidRole = raid.Roles.FirstOrDefault(r => r.IsRandomSignUpRole, CreateRandomSignUpRole(raid.RaidType));
|
||||||
}
|
}
|
||||||
|
await LogSignUp(signUp, signedOffByUserId);
|
||||||
}
|
}
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
_discordService.PostRaidMessage(raidId);
|
await _discordService.PostRaidMessage(raidId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SignOffExternalUser(int raidId, string userName, ulong signedOffByUserId)
|
||||||
|
{
|
||||||
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
|
||||||
|
List<RaidSignUp> signUps = context.RaidSignUps.Where(x => x.RaidId == raidId && x.ExternalUserName == userName).ToList();
|
||||||
|
context.RaidSignUps.RemoveRange(signUps);
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
RaidSignUp signUp = signUps.FirstOrDefault();
|
||||||
|
if(signUp != null)
|
||||||
|
{
|
||||||
|
signUp.SignUpType = SignUpType.SignedOff;
|
||||||
|
await LogSignUp(signUp, signedOffByUserId);
|
||||||
|
}
|
||||||
|
await _discordService.PostRaidMessage(raidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ChangeAccount(int raidId, ulong liebUserId, int guildWars2AccountId)
|
public async Task ChangeAccount(int raidId, ulong liebUserId, int guildWars2AccountId)
|
||||||
|
@ -159,10 +202,10 @@ namespace Lieb.Data
|
||||||
signUp.GuildWars2AccountId = guildWars2AccountId;
|
signUp.GuildWars2AccountId = guildWars2AccountId;
|
||||||
}
|
}
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
_discordService.PostRaidMessage(raidId);
|
await _discordService.PostRaidMessage(raidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeSignUpType(int raidId, ulong liebUserId, int plannedRoleId, SignUpType signUpType)
|
public async Task ChangeSignUpType(int raidId, ulong liebUserId, int plannedRoleId, SignUpType signUpType, bool postChanges = true)
|
||||||
{
|
{
|
||||||
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
||||||
{
|
{
|
||||||
|
@ -187,9 +230,13 @@ namespace Lieb.Data
|
||||||
{
|
{
|
||||||
signUp.RaidRoleId = plannedRoleId;
|
signUp.RaidRoleId = plannedRoleId;
|
||||||
signUp.SignUpType = signUpType;
|
signUp.SignUpType = signUpType;
|
||||||
|
await LogSignUp(signUp);
|
||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
_discordService.PostRaidMessage(raidId);
|
if(postChanges)
|
||||||
|
{
|
||||||
|
await _discordService.PostRaidMessage(raidId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRoleSignUpAllowed(ulong liebUserId, int plannedRoleId, SignUpType signUpType)
|
public bool IsRoleSignUpAllowed(ulong liebUserId, int plannedRoleId, SignUpType signUpType)
|
||||||
|
@ -276,7 +323,7 @@ namespace Lieb.Data
|
||||||
{
|
{
|
||||||
if (moveFlexUser)
|
if (moveFlexUser)
|
||||||
{
|
{
|
||||||
ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp);
|
await ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -340,20 +387,60 @@ namespace Lieb.Data
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendReminders()
|
private async Task LogSignUp(RaidSignUp signUp, ulong signedUpBy = 0)
|
||||||
|
{
|
||||||
|
RaidSignUpHistory history = new RaidSignUpHistory()
|
||||||
|
{
|
||||||
|
RaidId = signUp.RaidId,
|
||||||
|
UserId = signUp.LiebUserId,
|
||||||
|
SignUpType = signUp.SignUpType,
|
||||||
|
Time = DateTimeOffset.UtcNow,
|
||||||
|
UserName = signUp.ExternalUserName,
|
||||||
|
GuildWars2AccountId = signUp.GuildWars2AccountId
|
||||||
|
};
|
||||||
|
if(signedUpBy != 0)
|
||||||
|
{
|
||||||
|
history.UserId = signedUpBy;
|
||||||
|
}
|
||||||
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
await context.RaidSignUpHistories.AddAsync(history);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SendReminders()
|
||||||
{
|
{
|
||||||
using var context = _contextFactory.CreateDbContext();
|
using var context = _contextFactory.CreateDbContext();
|
||||||
|
DateTimeOffset now = DateTimeOffset.UtcNow;
|
||||||
List<Raid> raids = context.Raids
|
List<Raid> raids = context.Raids
|
||||||
.Include(r => r.Reminders)
|
.Include(r => r.Reminders)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach(Raid raid in raids)
|
foreach(Raid raid in raids.Where(r => r.StartTimeUTC > now))
|
||||||
{
|
{
|
||||||
foreach(RaidReminder reminder in raid.Reminders.Where(reminder => !reminder.Sent && raid.StartTimeUTC.AddHours(-reminder.HoursBeforeRaid) < DateTime.UtcNow))
|
foreach(RaidReminder reminder in raid.Reminders.Where(reminder => !reminder.Sent && raid.StartTimeUTC.AddHours(-reminder.HoursBeforeRaid) < DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
//TODO send reminders -> this is a Discord Problem...
|
switch(reminder.Type)
|
||||||
|
{
|
||||||
|
case RaidReminder.ReminderType.User:
|
||||||
|
await _discordService.SendUserReminder(reminder);
|
||||||
|
break;
|
||||||
|
case RaidReminder.ReminderType.Channel:
|
||||||
|
await _discordService.SendChannelReminder(reminder);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RaidRole CreateRandomSignUpRole(RaidType raidType)
|
||||||
|
{
|
||||||
|
return new RaidRole()
|
||||||
|
{
|
||||||
|
Spots = 10,
|
||||||
|
Name = "Random",
|
||||||
|
Description = raidType.ToString(),
|
||||||
|
IsRandomSignUpRole = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Lieb.Data
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckRaids(object? state)
|
private async void CheckRaids(object? state)
|
||||||
{
|
{
|
||||||
using (var scope = _services.CreateScope())
|
using (var scope = _services.CreateScope())
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ namespace Lieb.Data
|
||||||
var raidService =
|
var raidService =
|
||||||
scope.ServiceProvider
|
scope.ServiceProvider
|
||||||
.GetRequiredService<RaidService>();
|
.GetRequiredService<RaidService>();
|
||||||
raidService.SendReminders();
|
await raidService.SendReminders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,12 @@
|
||||||
public class RaidSignUp
|
public class RaidSignUp
|
||||||
{
|
{
|
||||||
public int RaidSignUpId { get; set; }
|
public int RaidSignUpId { get; set; }
|
||||||
|
public bool IsExternalUser {get { return LiebUserId == 0;}}
|
||||||
public int RaidId { get; set; }
|
public int RaidId { get; set; }
|
||||||
public ulong LiebUserId { get; set; }
|
public ulong LiebUserId { get; set; }
|
||||||
public int GuildWars2AccountId { get; set; }
|
public int GuildWars2AccountId { get; set; }
|
||||||
public int RaidRoleId { get; set; }
|
public int RaidRoleId { get; set; }
|
||||||
|
public string ExternalUserName {get; set;} = string.Empty;
|
||||||
|
|
||||||
public SignUpType SignUpType { get; set; }
|
public SignUpType SignUpType { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,25 @@
|
||||||
{
|
{
|
||||||
public int RaidSignUpHistoryId { get; set; }
|
public int RaidSignUpHistoryId { get; set; }
|
||||||
|
|
||||||
public string UserName { get; set; } = string.Empty;
|
public int RaidId { get; set; }
|
||||||
|
|
||||||
|
public ulong UserId {get; set;}
|
||||||
|
public int GuildWars2AccountId { get; set; }
|
||||||
|
|
||||||
|
//public ulong SignedUpByUserId {get; set;}
|
||||||
|
|
||||||
|
public string UserName {get; set;} = string.Empty;
|
||||||
|
|
||||||
public DateTimeOffset Time { get; set; } = DateTimeOffset.Now;
|
public DateTimeOffset Time { get; set; } = DateTimeOffset.Now;
|
||||||
|
|
||||||
public SignUpType SignUpType { get; set; }
|
public SignUpType SignUpType { get; set; }
|
||||||
|
|
||||||
|
public LiebUser User {get; set;}
|
||||||
|
|
||||||
|
//public LiebUser SignedUpByUser {get; set;}
|
||||||
|
|
||||||
public Raid Raid { get; set; }
|
public Raid Raid { get; set; }
|
||||||
|
|
||||||
|
public GuildWars2Account GuildWars2Account { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
@if (_user != null && _isRaidSignUpAllowed)
|
@if (_user != null && _isRaidSignUpAllowed)
|
||||||
{
|
{
|
||||||
<div class="signUpStatusTooltip">
|
<div class="signUpStatusTooltip">
|
||||||
@if(_raid.SignUps.Where(s => s.LiebUserId == _user.Id && s.SignUpType != SignUpType.SignedOff).Any())
|
@if(_raid.SignUps.Where(s => s.LiebUserId == _user.Id && s.SignUpType != SignUpType.SignedOff && s.LiebUserId > 0).Any())
|
||||||
{
|
{
|
||||||
<span class="oi oi-badge" style="color:green"></span>
|
<span class="oi oi-badge" style="color:green"></span>
|
||||||
<span class="tooltiptext">You are signed up</span>
|
<span class="tooltiptext">You are signed up</span>
|
||||||
|
|
|
@ -234,8 +234,8 @@
|
||||||
{
|
{
|
||||||
_raid = RaidService.GetRaid(parsedId);
|
_raid = RaidService.GetRaid(parsedId);
|
||||||
|
|
||||||
if (_raid != null && (_raid.RaidOwnerId == _user.Id
|
if (_raid.RaidOwnerId == _user.Id
|
||||||
|| _user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.RaidEditPowerLevel))
|
|| _user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.RaidEditPowerLevel)
|
||||||
{
|
{
|
||||||
_startTime = await TimeZoneService.GetLocalDateTime(_raid.StartTimeUTC);
|
_startTime = await TimeZoneService.GetLocalDateTime(_raid.StartTimeUTC);
|
||||||
_endTime = await TimeZoneService.GetLocalDateTime(_raid.EndTimeUTC);
|
_endTime = await TimeZoneService.GetLocalDateTime(_raid.EndTimeUTC);
|
||||||
|
@ -301,13 +301,7 @@
|
||||||
{
|
{
|
||||||
if(!_raid.Roles.Where(r => r.IsRandomSignUpRole).Any())
|
if(!_raid.Roles.Where(r => r.IsRandomSignUpRole).Any())
|
||||||
{
|
{
|
||||||
_raid.Roles.Add(new RaidRole()
|
_raid.Roles.Add(RaidService.CreateRandomSignUpRole(_raid.RaidType));
|
||||||
{
|
|
||||||
Spots = 10,
|
|
||||||
Name = "Random",
|
|
||||||
Description = _raid.RaidType.ToString(),
|
|
||||||
IsRandomSignUpRole = true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(RaidRole role in _raid.Roles.Where(r => !r.IsRandomSignUpRole))
|
foreach(RaidRole role in _raid.Roles.Where(r => !r.IsRandomSignUpRole))
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@{
|
@{
|
||||||
bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff).Any();
|
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))
|
@foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.RaidRoleId))
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,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)
|
||||||
{
|
{
|
||||||
RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType);
|
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
@{
|
@{
|
||||||
bool isUser = signUp.LiebUserId == _liebUserId;
|
bool isLoggedInUser = signUp.LiebUserId == _liebUserId;
|
||||||
string signUpStatus = string.Empty;
|
string signUpStatus = string.Empty;
|
||||||
@if (signUp.SignUpType != SignUpType.SignedUp && _signUpTypes.Count > 1) signUpStatus = $" - {signUp.SignUpType}";
|
@if (signUp.SignUpType != SignUpType.SignedUp && _signUpTypes.Count > 1) signUpStatus = $" - {signUp.SignUpType}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (isUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex)
|
@if (isLoggedInUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex)
|
||||||
{
|
{
|
||||||
<td>
|
<td>
|
||||||
<select class="accountselect" value=@signUp.GuildWars2AccountId @onchange="args => _Parent.ChangeAccount(args)">
|
<select class="accountselect" value=@signUp.GuildWars2AccountId @onchange="args => _Parent.ChangeAccount(args)">
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
</select> @signUpStatus
|
</select> @signUpStatus
|
||||||
</td>
|
</td>
|
||||||
}
|
}
|
||||||
else if(isUser && _showUserColor)
|
else if(isLoggedInUser && _showUserColor)
|
||||||
{
|
{
|
||||||
<td class="nametooltip username">
|
<td class="nametooltip username">
|
||||||
@signUp.GuildWars2Account.AccountName @signUpStatus
|
@signUp.GuildWars2Account.AccountName @signUpStatus
|
||||||
|
@ -39,13 +39,23 @@
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
}
|
}
|
||||||
|
else if(!signUp.IsExternalUser)
|
||||||
|
{
|
||||||
|
<td class="nametooltip">
|
||||||
|
@signUp.GuildWars2Account.AccountName @signUpStatus
|
||||||
|
@if(_showToolTip)
|
||||||
|
{
|
||||||
|
<span class="tooltiptext">@signUp.LiebUser.Name</span>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<td class="nametooltip">
|
<td class="nametooltip">
|
||||||
@signUp.GuildWars2Account.AccountName @signUpStatus
|
@signUp.ExternalUserName @signUpStatus
|
||||||
@if(_showToolTip)
|
@if(_showToolTip)
|
||||||
{
|
{
|
||||||
<span class="tooltiptext">@signUp.LiebUser.Name</span>
|
<span class="tooltiptext">external user</span>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue