mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
await usings and minor cleanup
This commit is contained in:
@@ -49,7 +49,7 @@ public sealed partial class Music
|
||||
|
||||
List<MusicPlaylist> playlists;
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
playlists = uow.MusicPlaylists.GetPlaylistsOnPage(num);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public sealed partial class Music
|
||||
var success = false;
|
||||
try
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var pl = uow.MusicPlaylists.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed partial class Music
|
||||
return;
|
||||
|
||||
MusicPlaylist mpl;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public sealed partial class Music
|
||||
}).ToList();
|
||||
|
||||
MusicPlaylist playlist;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
playlist = new()
|
||||
{
|
||||
@@ -203,7 +203,7 @@ public sealed partial class Music
|
||||
}
|
||||
|
||||
MusicPlaylist mpl;
|
||||
using (var uow = _db.GetDbContext())
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||
}
|
||||
|
@@ -345,8 +345,8 @@ public sealed class MusicService : IMusicService
|
||||
{
|
||||
if (_settings.TryGetValue(guildId, out var settings))
|
||||
return settings;
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
|
||||
await using var uow = _db.GetDbContext();
|
||||
var toReturn = _settings[guildId] = await uow.MusicPlayerSettings.ForGuildAsync(guildId);
|
||||
await uow.SaveChangesAsync();
|
||||
|
||||
@@ -358,7 +358,7 @@ public sealed class MusicService : IMusicService
|
||||
Action<MusicPlayerSettings, TState> action,
|
||||
TState state)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var ms = await uow.MusicPlayerSettings.ForGuildAsync(guildId);
|
||||
action(ms, state);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -438,7 +438,7 @@ public sealed class MusicService : IMusicService
|
||||
|
||||
public async Task<QualityPreset> GetMusicQualityAsync(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
var settings = await uow.MusicPlayerSettings.ForGuildAsync(guildId);
|
||||
return settings.QualityPreset;
|
||||
}
|
||||
|
Reference in New Issue
Block a user