fixed errors while logging raids
SQlite is now also used in production
This commit is contained in:
parent
7d6bc48dba
commit
fc5e75cc9d
5 changed files with 12 additions and 20 deletions
|
@ -58,9 +58,6 @@ namespace Lieb.Data
|
||||||
if (raid.RaidId == 0)
|
if (raid.RaidId == 0)
|
||||||
{
|
{
|
||||||
context.Raids.Add(raid);
|
context.Raids.Add(raid);
|
||||||
RaidLog log = RaidLog.CreateRaidLog(changedBy, raid);
|
|
||||||
await context.RaidLogs.AddAsync(log);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -79,11 +76,11 @@ namespace Lieb.Data
|
||||||
}
|
}
|
||||||
context.RaidRoles.RemoveRange(raid.Roles.Where(r => !r.IsRandomSignUpRole));
|
context.RaidRoles.RemoveRange(raid.Roles.Where(r => !r.IsRandomSignUpRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
RaidLog log = RaidLog.CreateRaidLog(changedBy, raid);
|
|
||||||
await context.RaidLogs.AddAsync(log);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
RaidLog log = RaidLog.CreateRaidLog(changedBy, raid);
|
||||||
|
await context.RaidLogs.AddAsync(log);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
await _discordService.PostRaidMessage(raid.RaidId);
|
await _discordService.PostRaidMessage(raid.RaidId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,6 @@ namespace Lieb.Data
|
||||||
if (template.RaidTemplateId == 0)
|
if (template.RaidTemplateId == 0)
|
||||||
{
|
{
|
||||||
context.RaidTemplates.Add(template);
|
context.RaidTemplates.Add(template);
|
||||||
RaidLog log = RaidLog.CreateRaidTemplateLog(changedBy, template);
|
|
||||||
await context.RaidLogs.AddAsync(log);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -48,10 +46,11 @@ namespace Lieb.Data
|
||||||
context.RaidRoles.RemoveRange(rolesToDelete);
|
context.RaidRoles.RemoveRange(rolesToDelete);
|
||||||
context.RaidReminders.RemoveRange(remindersToDelete);
|
context.RaidReminders.RemoveRange(remindersToDelete);
|
||||||
context.DiscordRaidMessages.RemoveRange(messagesToDelete);
|
context.DiscordRaidMessages.RemoveRange(messagesToDelete);
|
||||||
RaidLog log = RaidLog.CreateRaidTemplateLog(changedBy, template);
|
|
||||||
await context.RaidLogs.AddAsync(log);
|
|
||||||
}
|
}
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
RaidLog log = RaidLog.CreateRaidTemplateLog(changedBy, template);
|
||||||
|
await context.RaidLogs.AddAsync(log);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
public static RaidLog CreateRaidLog(ulong userId, Raid raid)
|
public static RaidLog CreateRaidLog(ulong userId, Raid raid)
|
||||||
{
|
{
|
||||||
raid.RaidLogs.Clear();
|
raid.RaidLogs.Clear();
|
||||||
|
raid.Reminders.Clear();
|
||||||
return new RaidLog()
|
return new RaidLog()
|
||||||
{
|
{
|
||||||
Type = LogType.Raid,
|
Type = LogType.Raid,
|
||||||
|
@ -61,6 +62,7 @@ namespace Lieb.Models.GuildWars2.Raid
|
||||||
public static RaidLog CreateRaidTemplateLog(ulong userId, RaidTemplate template)
|
public static RaidLog CreateRaidTemplateLog(ulong userId, RaidTemplate template)
|
||||||
{
|
{
|
||||||
template.TemplateLogs.Clear();
|
template.TemplateLogs.Clear();
|
||||||
|
template.Reminders.Clear();
|
||||||
return new RaidLog()
|
return new RaidLog()
|
||||||
{
|
{
|
||||||
Type = LogType.RaidTemplate,
|
Type = LogType.RaidTemplate,
|
||||||
|
|
|
@ -9,14 +9,8 @@ var builder = WebApplication.CreateBuilder(args);
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
builder.Services.AddDbContextFactory<LiebContext>(opt =>
|
builder.Services.AddDbContextFactory<LiebContext>(opt =>
|
||||||
//opt.UseSqlServer(builder.Configuration.GetConnectionString("LiebContext")).EnableSensitiveDataLogging(), ServiceLifetime.Transient);
|
|
||||||
opt.UseSqlite(builder.Configuration.GetConnectionString("LiebContext")));
|
opt.UseSqlite(builder.Configuration.GetConnectionString("LiebContext")));
|
||||||
#else
|
|
||||||
builder.Services.AddDbContextFactory<LiebContext>(opt =>
|
|
||||||
opt.UseMySql(builder.Configuration.GetConnectionString("LiebContext"), ServerVersion.AutoDetect(builder.Configuration.GetConnectionString("LiebContext"))), ServiceLifetime.Transient);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"LiebContext": "Server=liebdb;Database=LiebContext;Uid=root;Pwd=my-secret-pw;"
|
"LiebContext": "Data Source=/database/mydb.sqlite;"
|
||||||
},
|
},
|
||||||
"HttpClients": {
|
"HttpClients": {
|
||||||
"DiscordBot": "discord-bot"
|
"DiscordBot": "lieb-bot"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue