.qid cleaned up
This commit is contained in:
parent
b78f9dfd8c
commit
2e541eebac
2 changed files with 9 additions and 11 deletions
|
@ -106,13 +106,7 @@ public partial class Utility
|
|||
[RequireContext(ContextType.Guild)]
|
||||
public async Task QuoteShow(kwum quoteId)
|
||||
{
|
||||
Quote? quote;
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quote = uow.Set<Quote>().GetById(quoteId);
|
||||
if (quote?.GuildId != ctx.Guild.Id)
|
||||
quote = null;
|
||||
}
|
||||
var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId);
|
||||
|
||||
if (quote is null)
|
||||
{
|
||||
|
@ -224,9 +218,9 @@ public partial class Utility
|
|||
if (quoteId < 0)
|
||||
return;
|
||||
|
||||
var quote = await _service.GetQuoteByIdAsync(quoteId);
|
||||
var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId);
|
||||
|
||||
if (quote is null || quote.GuildId != ctx.Guild.Id)
|
||||
if (quote is null)
|
||||
{
|
||||
await Response().Error(strs.quotes_notfound).SendAsync();
|
||||
return;
|
||||
|
|
|
@ -118,9 +118,13 @@ public sealed class QuoteService : IQuoteService, IEService
|
|||
return count;
|
||||
}
|
||||
|
||||
public async Task<Quote> GetQuoteByIdAsync(kwum quoteId)
|
||||
public async Task<Quote?> GetQuoteByIdAsync(ulong guildId, kwum quoteId)
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
return uow.Set<Quote>().GetById(quoteId);
|
||||
|
||||
var quote = await uow.GetTable<Quote>()
|
||||
.Where(x => x.Id == quoteId && x.GuildId == guildId)
|
||||
.FirstAsyncLinqToDB();
|
||||
return quote;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue