public async Task DeleteAsync(ulong userId, int backgroundId) { var backInv = new RiftBackgroundInventory { UserId = userId, BackgroundId = backgroundId }; await DeleteAsync(backInv); }
public async Task DeleteAsync(RiftBackgroundInventory backInv) { await using var context = new RiftContext(); if (await context.BackgroundInventories .AsQueryable() .AnyAsync(x => x.Equals(backInv))) { context.BackgroundInventories.Remove(backInv); await context.SaveChangesAsync(); } }
public async Task AddAsync(ulong userId, int backgroundId) { if (!await DB.Users.EnsureExistsAsync(userId)) { throw new DatabaseException(nameof(BackgroundInventory) + nameof(AddAsync)); } var backInv = new RiftBackgroundInventory { UserId = userId, BackgroundId = backgroundId }; await using var context = new RiftContext(); await context.BackgroundInventories.AddAsync(backInv); await context.SaveChangesAsync(); }