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" };
|
||||
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=194863625477816321, 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} },
|
||||
#if DEBUG
|
||||
new LiebUser{Id=194455125769715713, Name="Lisa", GuildWars2Accounts = new List<GuildWars2Account>(){ hierpiepts}},
|
||||
new LiebUser{Id=2, Name="Simon", GuildWars2Accounts = new List<GuildWars2Account>(){ bloodseeker}}
|
||||
|
|
|
@ -26,43 +26,44 @@ namespace Lieb.Data
|
|||
|
||||
public async Task PostRaidMessage(int raidId)
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
Raid raid = context.Raids
|
||||
.Include(r => r.Roles)
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.LiebUser)
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.GuildWars2Account)
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.RaidRole)
|
||||
.Include(r => r.DiscordRaidMessages)
|
||||
.FirstOrDefault(r => r.RaidId == raidId);
|
||||
await PostRaidMessage(raid);
|
||||
}
|
||||
|
||||
public async Task PostRaidMessage(Raid raid)
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
ApiRaid apiRaid = ConvertRaid(raid);
|
||||
|
||||
var raidItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiRaid),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
string json = JsonSerializer.Serialize(apiRaid);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/PostRaidMessage", raidItemJson);
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
try
|
||||
{
|
||||
using var contentStream =
|
||||
await httpResponseMessage.Content.ReadAsStreamAsync();
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
Raid raid = context.Raids
|
||||
.Include(r => r.Roles)
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.LiebUser)
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.GuildWars2Account)
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.RaidRole)
|
||||
.Include(r => r.DiscordRaidMessages)
|
||||
.ToList()
|
||||
.FirstOrDefault(r => r.RaidId == raidId, new Raid());
|
||||
|
||||
ApiRaid returnedRaid = await JsonSerializer.DeserializeAsync<ApiRaid>(contentStream, _serializerOptions);
|
||||
await UpdateDiscordMessages(returnedRaid.DisocrdMessages, raid);
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
ApiRaid apiRaid = ConvertRaid(raid);
|
||||
|
||||
var raidItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiRaid),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
string json = JsonSerializer.Serialize(apiRaid);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/PostRaidMessage", raidItemJson);
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
using var contentStream =
|
||||
await httpResponseMessage.Content.ReadAsStreamAsync();
|
||||
|
||||
ApiRaid returnedRaid = await JsonSerializer.DeserializeAsync<ApiRaid>(contentStream, _serializerOptions);
|
||||
await UpdateDiscordMessages(returnedRaid.DisocrdMessages, raid);
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
public async Task DeleteRaidMessages(Raid raid)
|
||||
|
@ -72,18 +73,22 @@ namespace Lieb.Data
|
|||
|
||||
public async Task DeleteRaidMessages(IEnumerable<DiscordRaidMessage> messages)
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
try
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
IEnumerable<ApiRaid.DiscordMessage> apiMessages = ConvertMessages(messages);
|
||||
IEnumerable<ApiRaid.DiscordMessage> apiMessages = ConvertMessages(messages);
|
||||
|
||||
var messageItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiMessages),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
var messageItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiMessages),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/DeleteRaidMessage", messageItemJson);
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/DeleteRaidMessage", messageItemJson);
|
||||
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
public async Task<List<DiscordServer>> GetServers()
|
||||
|
@ -102,62 +107,67 @@ namespace Lieb.Data
|
|||
return await JsonSerializer.DeserializeAsync<List<DiscordServer>>(contentStream, _serializerOptions);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
catch {}
|
||||
return new List<DiscordServer>();
|
||||
}
|
||||
|
||||
public async Task SendUserReminder(RaidReminder reminder)
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
Raid raid = context.Raids
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.LiebUser)
|
||||
.FirstOrDefault(r => r.RaidId == reminder.RaidId);
|
||||
|
||||
if(raid == null) return;
|
||||
|
||||
ApiUserReminder apiReminder = ConvertUserReminder(reminder, raid);
|
||||
|
||||
var raidItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiReminder),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/SendUserReminder", raidItemJson);
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
try
|
||||
{
|
||||
reminder.Sent = true;
|
||||
context.Update(reminder);
|
||||
await context.SaveChangesAsync();
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
Raid raid = context.Raids
|
||||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.LiebUser)
|
||||
.FirstOrDefault(r => r.RaidId == reminder.RaidId);
|
||||
|
||||
if(raid == null) return;
|
||||
|
||||
ApiUserReminder apiReminder = ConvertUserReminder(reminder, raid);
|
||||
|
||||
var raidItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiReminder),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/SendUserReminder", raidItemJson);
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
reminder.Sent = true;
|
||||
context.Update(reminder);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
public async Task SendChannelReminder(RaidReminder reminder)
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
ApiChannelReminder apiReminder = ConvertChannelReminder(reminder);
|
||||
|
||||
var raidItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiReminder),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/SendChannelReminder", raidItemJson);
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
try
|
||||
{
|
||||
reminder.Sent = true;
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
context.Update(reminder);
|
||||
await context.SaveChangesAsync();
|
||||
var httpClient = _httpClientFactory.CreateClient(Constants.HttpClientName);
|
||||
|
||||
ApiChannelReminder apiReminder = ConvertChannelReminder(reminder);
|
||||
|
||||
var raidItemJson = new StringContent(
|
||||
JsonSerializer.Serialize(apiReminder),
|
||||
Encoding.UTF8,
|
||||
Application.Json);
|
||||
|
||||
var httpResponseMessage = await httpClient.PostAsync("raid/SendChannelReminder", raidItemJson);
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
reminder.Sent = true;
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
context.Update(reminder);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
private async Task UpdateDiscordMessages(IEnumerable<ApiRaid.DiscordMessage> messages, Raid raid)
|
||||
|
@ -206,12 +216,24 @@ namespace Lieb.Data
|
|||
{
|
||||
if(signUp.SignUpType != SignUpType.SignedOff)
|
||||
{
|
||||
string status = signUp.SignUpType != SignUpType.SignedUp ? signUp.SignUpType.ToString() : string.Empty;
|
||||
apiRole.Users.Add(new ApiRaid.Role.User(){
|
||||
AccountName = signUp.GuildWars2Account.AccountName,
|
||||
Status = status,
|
||||
UserName = signUp.LiebUser.Name
|
||||
});
|
||||
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;
|
||||
apiRole.Users.Add(new ApiRaid.Role.User(){
|
||||
AccountName = signUp.GuildWars2Account.AccountName,
|
||||
Status = status,
|
||||
UserName = signUp.LiebUser.Name
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
apiRaid.Roles.Add(apiRole);
|
||||
|
|
|
@ -46,7 +46,8 @@ namespace Lieb.Data
|
|||
.Include(r => r.SignUps)
|
||||
.ThenInclude(s => s.RaidRole)
|
||||
.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)
|
||||
|
@ -69,7 +70,7 @@ namespace Lieb.Data
|
|||
//move users back to "Random" role
|
||||
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)
|
||||
{
|
||||
signUp.RaidRole = randomRole;
|
||||
|
@ -79,7 +80,7 @@ namespace Lieb.Data
|
|||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
_discordService.PostRaidMessage(raid.RaidId);
|
||||
await _discordService.PostRaidMessage(raid.RaidId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +95,7 @@ namespace Lieb.Data
|
|||
await context.SaveChangesAsync();
|
||||
context.Raids.Remove(raid);
|
||||
await context.SaveChangesAsync();
|
||||
_discordService.DeleteRaidMessages(raid);
|
||||
await _discordService.DeleteRaidMessages(raid);
|
||||
}
|
||||
|
||||
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();
|
||||
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())
|
||||
{
|
||||
context.RaidSignUps.Add(new RaidSignUp()
|
||||
RaidSignUp signUp = new RaidSignUp()
|
||||
{
|
||||
GuildWars2AccountId = guildWars2AccountId,
|
||||
RaidId = raidId,
|
||||
LiebUserId = liebUserId,
|
||||
RaidRoleId = plannedRoleId,
|
||||
SignUpType = signUpType
|
||||
});
|
||||
};
|
||||
context.RaidSignUps.Add(signUp);
|
||||
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();
|
||||
//remove Flex Sign Ups
|
||||
|
@ -143,11 +168,29 @@ namespace Lieb.Data
|
|||
if(raid != null && raid.RaidType != RaidType.Planned && !signUp.RaidRole.IsRandomSignUpRole)
|
||||
{
|
||||
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();
|
||||
_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)
|
||||
|
@ -159,10 +202,10 @@ namespace Lieb.Data
|
|||
signUp.GuildWars2AccountId = guildWars2AccountId;
|
||||
}
|
||||
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))
|
||||
{
|
||||
|
@ -187,9 +230,13 @@ namespace Lieb.Data
|
|||
{
|
||||
signUp.RaidRoleId = plannedRoleId;
|
||||
signUp.SignUpType = signUpType;
|
||||
await LogSignUp(signUp);
|
||||
}
|
||||
context.SaveChanges();
|
||||
_discordService.PostRaidMessage(raidId);
|
||||
if(postChanges)
|
||||
{
|
||||
await _discordService.PostRaidMessage(raidId);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRoleSignUpAllowed(ulong liebUserId, int plannedRoleId, SignUpType signUpType)
|
||||
|
@ -276,7 +323,7 @@ namespace Lieb.Data
|
|||
{
|
||||
if (moveFlexUser)
|
||||
{
|
||||
ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp);
|
||||
await ChangeSignUpType(raid.RaidId, userId, signUp.RaidRoleId, SignUpType.SignedUp, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -340,20 +387,60 @@ namespace Lieb.Data
|
|||
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();
|
||||
DateTimeOffset now = DateTimeOffset.UtcNow;
|
||||
List<Raid> raids = context.Raids
|
||||
.Include(r => r.Reminders)
|
||||
.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))
|
||||
{
|
||||
//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;
|
||||
}
|
||||
|
||||
private void CheckRaids(object? state)
|
||||
private async void CheckRaids(object? state)
|
||||
{
|
||||
using (var scope = _services.CreateScope())
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ namespace Lieb.Data
|
|||
var raidService =
|
||||
scope.ServiceProvider
|
||||
.GetRequiredService<RaidService>();
|
||||
raidService.SendReminders();
|
||||
await raidService.SendReminders();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
public class RaidSignUp
|
||||
{
|
||||
public int RaidSignUpId { get; set; }
|
||||
|
||||
public bool IsExternalUser {get { return LiebUserId == 0;}}
|
||||
public int RaidId { get; set; }
|
||||
public ulong LiebUserId { get; set; }
|
||||
public int GuildWars2AccountId { get; set; }
|
||||
public int RaidRoleId { get; set; }
|
||||
public string ExternalUserName {get; set;} = string.Empty;
|
||||
|
||||
public SignUpType SignUpType { get; set; }
|
||||
|
||||
|
|
|
@ -4,12 +4,25 @@
|
|||
{
|
||||
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 SignUpType SignUpType { get; set; }
|
||||
|
||||
public LiebUser User {get; set;}
|
||||
|
||||
//public LiebUser SignedUpByUser {get; set;}
|
||||
|
||||
public Raid Raid { get; set; }
|
||||
|
||||
public GuildWars2Account GuildWars2Account { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
@if (_user != null && _isRaidSignUpAllowed)
|
||||
{
|
||||
<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="tooltiptext">You are signed up</span>
|
||||
|
|
|
@ -234,8 +234,8 @@
|
|||
{
|
||||
_raid = RaidService.GetRaid(parsedId);
|
||||
|
||||
if (_raid != null && (_raid.RaidOwnerId == _user.Id
|
||||
|| _user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.RaidEditPowerLevel))
|
||||
if (_raid.RaidOwnerId == _user.Id
|
||||
|| _user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.RaidEditPowerLevel)
|
||||
{
|
||||
_startTime = await TimeZoneService.GetLocalDateTime(_raid.StartTimeUTC);
|
||||
_endTime = await TimeZoneService.GetLocalDateTime(_raid.EndTimeUTC);
|
||||
|
@ -301,13 +301,7 @@
|
|||
{
|
||||
if(!_raid.Roles.Where(r => r.IsRandomSignUpRole).Any())
|
||||
{
|
||||
_raid.Roles.Add(new RaidRole()
|
||||
{
|
||||
Spots = 10,
|
||||
Name = "Random",
|
||||
Description = _raid.RaidType.ToString(),
|
||||
IsRandomSignUpRole = true
|
||||
});
|
||||
_raid.Roles.Add(RaidService.CreateRandomSignUpRole(_raid.RaidType));
|
||||
}
|
||||
|
||||
foreach(RaidRole role in _raid.Roles.Where(r => !r.IsRandomSignUpRole))
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</thead>
|
||||
<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))
|
||||
{
|
||||
|
@ -141,7 +141,7 @@
|
|||
{
|
||||
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
|
||||
{
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
{
|
||||
<tr>
|
||||
@{
|
||||
bool isUser = signUp.LiebUserId == _liebUserId;
|
||||
bool isLoggedInUser = signUp.LiebUserId == _liebUserId;
|
||||
string signUpStatus = string.Empty;
|
||||
@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>
|
||||
<select class="accountselect" value=@signUp.GuildWars2AccountId @onchange="args => _Parent.ChangeAccount(args)">
|
||||
|
@ -29,7 +29,7 @@
|
|||
</select> @signUpStatus
|
||||
</td>
|
||||
}
|
||||
else if(isUser && _showUserColor)
|
||||
else if(isLoggedInUser && _showUserColor)
|
||||
{
|
||||
<td class="nametooltip username">
|
||||
@signUp.GuildWars2Account.AccountName @signUpStatus
|
||||
|
@ -39,13 +39,23 @@
|
|||
}
|
||||
</td>
|
||||
}
|
||||
else if(!signUp.IsExternalUser)
|
||||
{
|
||||
<td class="nametooltip">
|
||||
@signUp.GuildWars2Account.AccountName @signUpStatus
|
||||
@if(_showToolTip)
|
||||
{
|
||||
<span class="tooltiptext">@signUp.LiebUser.Name</span>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td class="nametooltip">
|
||||
@signUp.GuildWars2Account.AccountName @signUpStatus
|
||||
@signUp.ExternalUserName @signUpStatus
|
||||
@if(_showToolTip)
|
||||
{
|
||||
<span class="tooltiptext">@signUp.LiebUser.Name</span>
|
||||
<span class="tooltiptext">external user</span>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue