added needed rights for slash commands
added functions for account select in the bot
This commit is contained in:
parent
62bacb5ad7
commit
dc2563e16c
11 changed files with 876 additions and 13 deletions
|
@ -83,7 +83,7 @@ namespace Lieb.Controllers
|
|||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetMainAccount(signUp.userId).GuildWars2AccountId;
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.SignedUp, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
|
@ -98,7 +98,7 @@ namespace Lieb.Controllers
|
|||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetMainAccount(signUp.userId).GuildWars2AccountId;
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Maybe, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
|
@ -113,7 +113,7 @@ namespace Lieb.Controllers
|
|||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetMainAccount(signUp.userId).GuildWars2AccountId;
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Backup, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
|
@ -128,7 +128,7 @@ namespace Lieb.Controllers
|
|||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetMainAccount(signUp.userId).GuildWars2AccountId;
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Flex, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
|
@ -202,5 +202,41 @@ namespace Lieb.Controllers
|
|||
|
||||
return Problem("user not found");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]/{userId}/{raidId}")]
|
||||
public ActionResult<List<ApiGuildWars2Account>> GetSignUpAccounts(ulong userId, int raidId)
|
||||
{
|
||||
List<GuildWars2Account> accounts = _userService.GetDiscordSignUpAccounts(userId, raidId);
|
||||
List<ApiGuildWars2Account> apiAccounts = new List<ApiGuildWars2Account>();
|
||||
|
||||
foreach(GuildWars2Account account in accounts)
|
||||
{
|
||||
apiAccounts.Add(new ApiGuildWars2Account(){
|
||||
AccountName = account.AccountName,
|
||||
GuildWars2AccountId = account.GuildWars2AccountId
|
||||
});
|
||||
}
|
||||
return Ok(apiAccounts);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("[action]/{userId}/{command}")]
|
||||
public ActionResult IsSlashCommandAllowed(ulong userId, string command)
|
||||
{
|
||||
switch(command)
|
||||
{
|
||||
case SharedConstants.SlashCommands.RAID:
|
||||
if(!_raidService.IsRaidSlashCommandAllowed(userId, out string errorMessage))
|
||||
{
|
||||
return Problem(errorMessage);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return Problem("command not found on server");
|
||||
break;
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,6 +117,7 @@ namespace Lieb.Data
|
|||
if (signUpType != SignUpType.Flex && signUps.Where(r => r.SignUpType != SignUpType.Flex).Any())
|
||||
{
|
||||
await ChangeSignUpType(raidId, liebUserId, plannedRoleId, signUpType);
|
||||
await ChangeAccount(raidId, liebUserId, guildWars2AccountId);
|
||||
}
|
||||
else if (!signUps.Where(r => r.RaidRoleId == plannedRoleId).Any())
|
||||
{
|
||||
|
@ -417,6 +418,23 @@ namespace Lieb.Data
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool IsRaidSlashCommandAllowed(ulong liebUserId, out string errorMessage)
|
||||
{
|
||||
errorMessage = string.Empty;
|
||||
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
LiebUser user = context.LiebUsers
|
||||
.Include(u => u.RoleAssignments)
|
||||
.ThenInclude(a => a.LiebRole)
|
||||
.FirstOrDefault(u => u.Id == liebUserId);
|
||||
if (user != null && user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.Roles.RaidLead.PowerLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
errorMessage = "insufficient permissions";
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task LogSignUp(RaidSignUp signUp, string userName, ulong signedUpBy = 0)
|
||||
{
|
||||
ulong userId = signedUpBy > 0 ? signedUpBy : signUp.LiebUserId.Value;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Lieb.Models;
|
||||
using Lieb.Models.GuildWars2;
|
||||
using Lieb.Models.GuildWars2.Raid;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Lieb.Data
|
||||
|
@ -185,5 +186,66 @@ namespace Lieb.Data
|
|||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public List<GuildWars2Account> GetAllUsableAccounts(ulong userId, RaidType raidType)
|
||||
{
|
||||
LiebUser user = GetLiebUserGW2AccountOnly(userId);
|
||||
return GetAllUsableAccounts(user, raidType);
|
||||
}
|
||||
|
||||
public List<GuildWars2Account> GetAllUsableAccounts(LiebUser user, RaidType raidType)
|
||||
{
|
||||
if (raidType == RaidType.Planned)
|
||||
{
|
||||
return user.GuildWars2Accounts.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<GuildWars2Account> GetDiscordSignUpAccounts(ulong userId, int raidId)
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
LiebUser user = GetLiebUserGW2AccountOnly(userId);
|
||||
Raid raid = context.Raids
|
||||
.ToList()
|
||||
.FirstOrDefault(r => r.RaidId == raidId, new Raid());
|
||||
|
||||
List<GuildWars2Account> accounts = GetAllUsableAccounts(user, raid.RaidType);
|
||||
if(user.AlwaysSignUpWithMainAccount && accounts.Where(a => a.GuildWars2AccountId == user.MainGW2Account).Any())
|
||||
{
|
||||
return accounts.Where(a => a.GuildWars2AccountId == user.MainGW2Account).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return accounts;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSignUpAccount(ulong userId, int raidId, int plannedAccountId)
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
LiebUser user = GetLiebUserGW2AccountOnly(userId);
|
||||
Raid raid = context.Raids
|
||||
.ToList()
|
||||
.FirstOrDefault(r => r.RaidId == raidId, new Raid());
|
||||
|
||||
List<GuildWars2Account> usableAccounts = GetAllUsableAccounts(user, raid.RaidType);
|
||||
|
||||
if(usableAccounts.Where(a => a.GuildWars2AccountId == plannedAccountId).Any())
|
||||
{
|
||||
return plannedAccountId;
|
||||
}
|
||||
if(usableAccounts.Where(a => a.GuildWars2AccountId == user.MainGW2Account).Any())
|
||||
{
|
||||
return user.MainGW2Account;
|
||||
}
|
||||
else
|
||||
{
|
||||
return usableAccounts.First().GuildWars2AccountId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
698
Lieb/Migrations/20221128221654_AddAlwaysSignUpWithMainAccount.Designer.cs
generated
Normal file
698
Lieb/Migrations/20221128221654_AddAlwaysSignUpWithMainAccount.Designer.cs
generated
Normal file
|
@ -0,0 +1,698 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Lieb.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lieb.Migrations
|
||||
{
|
||||
[DbContext(typeof(LiebContext))]
|
||||
[Migration("20221128221654_AddAlwaysSignUpWithMainAccount")]
|
||||
partial class AddAlwaysSignUpWithMainAccount
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.DiscordSettings", b =>
|
||||
{
|
||||
b.Property<ulong>("DiscordSettingsId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("ChangeUserNames")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("DiscordLogChannel")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("DiscordSettingsId");
|
||||
|
||||
b.ToTable("DiscordSettings", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b =>
|
||||
{
|
||||
b.Property<int>("EquippedId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("CanTank")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("GuildWars2AccountId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("GuildWars2BuildId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("EquippedId");
|
||||
|
||||
b.HasIndex("GuildWars2AccountId");
|
||||
|
||||
b.HasIndex("GuildWars2BuildId");
|
||||
|
||||
b.ToTable("Equipped", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
|
||||
{
|
||||
b.Property<int>("GuildWars2AccountId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AccountName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ApiKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<ulong?>("LiebUserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("GuildWars2AccountId");
|
||||
|
||||
b.HasIndex("LiebUserId");
|
||||
|
||||
b.ToTable("GuildWars2Account", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b =>
|
||||
{
|
||||
b.Property<int>("GuildWars2BuildId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<short>("Alacrity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Class")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("EliteSpecialization")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<short>("Heal")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<short>("Might")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<short>("Quickness")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("GuildWars2BuildId");
|
||||
|
||||
b.ToTable("GuildWars2Build", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
|
||||
{
|
||||
b.Property<int>("DiscordRaidMessageId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("DiscordChannelId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("DiscordGuildId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("DiscordMessageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("RaidTemplateId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("DiscordRaidMessageId");
|
||||
|
||||
b.HasIndex("RaidId");
|
||||
|
||||
b.HasIndex("RaidTemplateId");
|
||||
|
||||
b.ToTable("DiscordRaidMessage", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.Raid", b =>
|
||||
{
|
||||
b.Property<int>("RaidId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTimeOffset>("EndTimeUTC")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTimeOffset>("FreeForAllTimeUTC")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Guild")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("MoveFlexUsers")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Organizer")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<ulong>("RaidOwnerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("RaidType")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("RequiredRole")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTimeOffset>("StartTimeUTC")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("VoiceChat")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("RaidId");
|
||||
|
||||
b.ToTable("Raid", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidLog", b =>
|
||||
{
|
||||
b.Property<int>("RaidLogId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("LogEntry")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("RaidTemplateId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTimeOffset>("Time")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("UserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("RaidLogId");
|
||||
|
||||
b.HasIndex("RaidId");
|
||||
|
||||
b.HasIndex("RaidTemplateId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("RaidLog", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
|
||||
{
|
||||
b.Property<int>("RaidReminderId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("DiscordChannelId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("DiscordServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("RaidTemplateId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTimeOffset>("ReminderTimeUTC")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Sent")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("TimeType")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("RaidReminderId");
|
||||
|
||||
b.HasIndex("RaidId");
|
||||
|
||||
b.HasIndex("RaidTemplateId");
|
||||
|
||||
b.ToTable("RaidReminder", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
|
||||
{
|
||||
b.Property<int>("RaidRoleId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsRandomSignUpRole")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("RaidTemplateId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Spots")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("RaidRoleId");
|
||||
|
||||
b.HasIndex("RaidId");
|
||||
|
||||
b.HasIndex("RaidTemplateId");
|
||||
|
||||
b.ToTable("RaidRole", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidSignUp", b =>
|
||||
{
|
||||
b.Property<int>("RaidSignUpId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ExternalUserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("GuildWars2AccountId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong?>("LiebUserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("RaidId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("RaidRoleId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("SignUpType")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("RaidSignUpId");
|
||||
|
||||
b.HasIndex("GuildWars2AccountId");
|
||||
|
||||
b.HasIndex("LiebUserId");
|
||||
|
||||
b.HasIndex("RaidId");
|
||||
|
||||
b.HasIndex("RaidRoleId");
|
||||
|
||||
b.ToTable("RaidSignUp", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b =>
|
||||
{
|
||||
b.Property<int>("RaidTemplateId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CreateDaysBefore")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("EndTime")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("FreeForAllTime")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Guild")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Interval")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("MoveFlexUsers")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Organizer")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<ulong>("RaidOwnerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("RaidType")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("RequiredRole")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("StartTime")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("TimeZone")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("VoiceChat")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("RaidTemplateId");
|
||||
|
||||
b.ToTable("RaidTemplate", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.LiebRole", b =>
|
||||
{
|
||||
b.Property<int>("LiebRoleId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Level")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("LevelToAssign")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("RoleName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("LiebRoleId");
|
||||
|
||||
b.ToTable("LiebRole", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.LiebUser", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("AlwaysSignUpWithMainAccount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime?>("BannedUntil")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("Birthday")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("MainGW2Account")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Pronouns")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LiebUser", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
|
||||
{
|
||||
b.Property<int>("RoleAssignmentId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("LiebRoleId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("LiebUserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("RoleAssignmentId");
|
||||
|
||||
b.HasIndex("LiebRoleId");
|
||||
|
||||
b.HasIndex("LiebUserId");
|
||||
|
||||
b.ToTable("RoleAssignment", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Equipped", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.GuildWars2Account", "GuildWars2Account")
|
||||
.WithMany("EquippedBuilds")
|
||||
.HasForeignKey("GuildWars2AccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.GuildWars2Build", "GuildWars2Build")
|
||||
.WithMany("EquippedRoles")
|
||||
.HasForeignKey("GuildWars2BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("GuildWars2Account");
|
||||
|
||||
b.Navigation("GuildWars2Build");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.LiebUser", null)
|
||||
.WithMany("GuildWars2Accounts")
|
||||
.HasForeignKey("LiebUserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.DiscordRaidMessage", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||
.WithMany("DiscordRaidMessages")
|
||||
.HasForeignKey("RaidId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||
.WithMany("DiscordRaidMessages")
|
||||
.HasForeignKey("RaidTemplateId");
|
||||
|
||||
b.Navigation("Raid");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidLog", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||
.WithMany("RaidLogs")
|
||||
.HasForeignKey("RaidId");
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", "RaidTemplate")
|
||||
.WithMany("TemplateLogs")
|
||||
.HasForeignKey("RaidTemplateId");
|
||||
|
||||
b.HasOne("Lieb.Models.LiebUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Raid");
|
||||
|
||||
b.Navigation("RaidTemplate");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidReminder", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||
.WithMany("Reminders")
|
||||
.HasForeignKey("RaidId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||
.WithMany("Reminders")
|
||||
.HasForeignKey("RaidTemplateId");
|
||||
|
||||
b.Navigation("Raid");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidRole", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", null)
|
||||
.WithMany("Roles")
|
||||
.HasForeignKey("RaidId");
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidTemplate", null)
|
||||
.WithMany("Roles")
|
||||
.HasForeignKey("RaidTemplateId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidSignUp", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.GuildWars2.GuildWars2Account", "GuildWars2Account")
|
||||
.WithMany()
|
||||
.HasForeignKey("GuildWars2AccountId");
|
||||
|
||||
b.HasOne("Lieb.Models.LiebUser", "LiebUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("LiebUserId");
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.Raid", "Raid")
|
||||
.WithMany("SignUps")
|
||||
.HasForeignKey("RaidId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lieb.Models.GuildWars2.Raid.RaidRole", "RaidRole")
|
||||
.WithMany()
|
||||
.HasForeignKey("RaidRoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("GuildWars2Account");
|
||||
|
||||
b.Navigation("LiebUser");
|
||||
|
||||
b.Navigation("Raid");
|
||||
|
||||
b.Navigation("RaidRole");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.RoleAssignment", b =>
|
||||
{
|
||||
b.HasOne("Lieb.Models.LiebRole", "LiebRole")
|
||||
.WithMany("RoleAssignments")
|
||||
.HasForeignKey("LiebRoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lieb.Models.LiebUser", "LiebUser")
|
||||
.WithMany("RoleAssignments")
|
||||
.HasForeignKey("LiebUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LiebRole");
|
||||
|
||||
b.Navigation("LiebUser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Account", b =>
|
||||
{
|
||||
b.Navigation("EquippedBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.GuildWars2Build", b =>
|
||||
{
|
||||
b.Navigation("EquippedRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.Raid", b =>
|
||||
{
|
||||
b.Navigation("DiscordRaidMessages");
|
||||
|
||||
b.Navigation("RaidLogs");
|
||||
|
||||
b.Navigation("Reminders");
|
||||
|
||||
b.Navigation("Roles");
|
||||
|
||||
b.Navigation("SignUps");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.GuildWars2.Raid.RaidTemplate", b =>
|
||||
{
|
||||
b.Navigation("DiscordRaidMessages");
|
||||
|
||||
b.Navigation("Reminders");
|
||||
|
||||
b.Navigation("Roles");
|
||||
|
||||
b.Navigation("TemplateLogs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.LiebRole", b =>
|
||||
{
|
||||
b.Navigation("RoleAssignments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lieb.Models.LiebUser", b =>
|
||||
{
|
||||
b.Navigation("GuildWars2Accounts");
|
||||
|
||||
b.Navigation("RoleAssignments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lieb.Migrations
|
||||
{
|
||||
public partial class AddAlwaysSignUpWithMainAccount : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "AlwaysSignUpWithMainAccount",
|
||||
table: "LiebUser",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AlwaysSignUpWithMainAccount",
|
||||
table: "LiebUser");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -457,6 +457,9 @@ namespace Lieb.Migrations
|
|||
b.Property<ulong>("Id")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("AlwaysSignUpWithMainAccount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime?>("BannedUntil")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Lieb.Models.GuildWars2.Raid
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Lieb.Models.GuildWars2.Raid
|
||||
{
|
||||
public enum SignUpType
|
||||
{
|
||||
|
@ -21,6 +23,7 @@
|
|||
|
||||
public SignUpType SignUpType { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||
public Raid Raid { get; set; }
|
||||
public LiebUser? LiebUser { get; set; }
|
||||
public GuildWars2Account? GuildWars2Account { get; set; }
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Lieb.Models
|
|||
public DateTime? Birthday { get; set; }
|
||||
public DateTime? BannedUntil { get; set; }
|
||||
public int MainGW2Account { get; set; }
|
||||
public bool AlwaysSignUpWithMainAccount { get; set; } = false;
|
||||
public ICollection<GuildWars2Account> GuildWars2Accounts { get; set; } = new List<GuildWars2Account>();
|
||||
public ICollection<RoleAssignment> RoleAssignments { get; set; } = new List<RoleAssignment>();
|
||||
}
|
||||
|
|
|
@ -118,14 +118,7 @@
|
|||
{
|
||||
if (_user != null)
|
||||
{
|
||||
if (_raid.RaidType == RaidType.Planned)
|
||||
{
|
||||
_usableAccounts = _user.GuildWars2Accounts.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
||||
}
|
||||
_usableAccounts = UserService.GetAllUsableAccounts(_user.Id, _raid.RaidType);
|
||||
_liebUserId = _user.Id;
|
||||
}
|
||||
_expandableRoles = new List<ExpandableRole>();
|
||||
|
@ -147,6 +140,10 @@
|
|||
else
|
||||
{
|
||||
int gw2AccountId = UserService.GetMainAccount(_liebUserId).GuildWars2AccountId;
|
||||
if(!_usableAccounts.Where(a => a.GuildWars2AccountId == gw2AccountId).Any())
|
||||
{
|
||||
gw2AccountId = _usableAccounts.FirstOrDefault().GuildWars2AccountId;
|
||||
}
|
||||
await RaidService.SignUp(_raid.RaidId, _liebUserId, gw2AccountId, role.RaidRoleId, signUpType);
|
||||
}
|
||||
_Parent.HasChanged();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue