public void RemoveUserStatistics(UserStatistics userStatistics) { using IServiceScope scope = _ScopeFactory.CreateScope(); DiscordBotDbContext context = scope.ServiceProvider.GetRequiredService <DiscordBotDbContext>(); context.UsersStatistics.Remove(userStatistics); }
public async Task <UserStatistics> GetUserStatistics(ulong guildId, string username) { using IServiceScope scope = _ScopeFactory.CreateScope(); DiscordBotDbContext context = scope.ServiceProvider.GetRequiredService <DiscordBotDbContext>(); return(await context.UsersStatistics.FindAsync(guildId, username)); }
public static async Task TestAsync(this DiscordBotDbContext dbContext) { /* * var member = new Member * { * SnowflakeId = 12345 * }; * * await dbContext.Members.AddAsync(member); * await dbContext.SaveChangesAsync(); */ var retrievedMember = await dbContext.Members.FirstOrDefaultAsync(); var project = new Project { Name = "MyProject", Author = retrievedMember, }; project.Members.Add(retrievedMember); await dbContext.Projects.AddAsync(project); await dbContext.SaveChangesAsync(); }
public async Task <UserStatistics> AddUserStatistics(UserStatistics userStatistics) { using IServiceScope scope = _ScopeFactory.CreateScope(); DiscordBotDbContext context = scope.ServiceProvider.GetRequiredService <DiscordBotDbContext>(); await context.UsersStatistics.AddAsync(userStatistics); return(userStatistics); }
/// <summary>Setup for the math module.</summary> public MathModule() { _discordBotDbContext = new DiscordBotDbContext(); }
public MembersController(DiscordBotDbContext dbContext) { _dbContext = dbContext; }
public ProjectsController(DiscordBotDbContext dbContext) { _dbContext = dbContext; }