fix: pass cancellationToken to library methods that accept them
This commit is contained in:
parent
afe626bd78
commit
91805bc9ad
@ -4,10 +4,10 @@ namespace cuqmbr.TravelGuide.Application.Common.Interfaces.Services;
|
||||
|
||||
public interface LiqPayPaymentService
|
||||
{
|
||||
Task<string> GetPaymentLinkAsync(
|
||||
string GetPaymentLink(
|
||||
decimal amount, Currency currency,
|
||||
string orderId, TimeSpan validity, string description,
|
||||
string resultPath, string callbackPath);
|
||||
|
||||
Task<bool> IsValidSignatureAsync(string postData, string postSignature);
|
||||
bool IsValidSignature(string postData, string postSignature);
|
||||
}
|
||||
|
@ -462,8 +462,8 @@ public class GetPaymentLinkCommandHandler :
|
||||
var resultPath = request.ResultPath;
|
||||
var callbackPath = "/payments/liqPay/ticket/callback";
|
||||
|
||||
var paymentLink = await _liqPayPaymentService
|
||||
.GetPaymentLinkAsync(
|
||||
var paymentLink = _liqPayPaymentService
|
||||
.GetPaymentLink(
|
||||
amount, Currency.UAH, guid.ToString(), validity,
|
||||
_localizer["PaymentProcessing.TicketPaymentDescription"],
|
||||
resultPath, callbackPath);
|
||||
|
@ -27,8 +27,8 @@ public class ProcessCallbackCommandHandler :
|
||||
ProcessCallbackCommand request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var isSignatureValid = await _liqPayPaymentService
|
||||
.IsValidSignatureAsync(request.Data, request.Signature);
|
||||
var isSignatureValid = _liqPayPaymentService
|
||||
.IsValidSignature(request.Data, request.Signature);
|
||||
|
||||
if (!isSignatureValid)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ public sealed class LiqPayPaymentService :
|
||||
configurationOptions.Value.PaymentProcessing.ResultAddressBase;
|
||||
}
|
||||
|
||||
public Task<string> GetPaymentLinkAsync(
|
||||
public string GetPaymentLink(
|
||||
decimal amount, Currency currency,
|
||||
string orderId, TimeSpan validity, string description,
|
||||
string resultPath, string callbackPath)
|
||||
@ -60,12 +60,12 @@ public sealed class LiqPayPaymentService :
|
||||
_configuration.PrivateKey)));
|
||||
|
||||
|
||||
return Task.FromResult(
|
||||
return
|
||||
"https://www.liqpay.ua/api/3/checkout" +
|
||||
$"?data={data}&signature={signature}");
|
||||
$"?data={data}&signature={signature}";
|
||||
}
|
||||
|
||||
public Task<bool> IsValidSignatureAsync(string postData, string postSignature)
|
||||
public bool IsValidSignature(string postData, string postSignature)
|
||||
{
|
||||
var signature = Convert.ToBase64String(SHA1.HashData(
|
||||
Encoding.UTF8.GetBytes(
|
||||
@ -73,6 +73,6 @@ public sealed class LiqPayPaymentService :
|
||||
postData +
|
||||
_configuration.PrivateKey)));
|
||||
|
||||
return Task.FromResult(postSignature.Equals(signature));
|
||||
return postSignature.Equals(signature);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public sealed class InMemoryUnitOfWork : UnitOfWork
|
||||
|
||||
public async Task<int> SaveAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return await _dbContext.SaveChangesAsync();
|
||||
return await _dbContext.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -28,7 +28,7 @@ public abstract class InMemoryBaseRepository<TEntity> : BaseRepository<TEntity>
|
||||
Expression<Func<TEntity, bool>> predicate,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _dbSet.SingleOrDefaultAsync(predicate);
|
||||
return await _dbSet.SingleOrDefaultAsync(predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<TEntity?> GetOneAsync(
|
||||
@ -39,19 +39,19 @@ public abstract class InMemoryBaseRepository<TEntity> : BaseRepository<TEntity>
|
||||
return
|
||||
await _dbSet
|
||||
.Include(includeSelector)
|
||||
.SingleOrDefaultAsync(predicate);
|
||||
.SingleOrDefaultAsync(predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<PaginatedList<TEntity>> GetPageAsync(
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.CountAsync();
|
||||
var count = await _dbSet.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -63,13 +63,13 @@ public abstract class InMemoryBaseRepository<TEntity> : BaseRepository<TEntity>
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.CountAsync();
|
||||
var count = await _dbSet.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.Include(includeSelector)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -81,13 +81,15 @@ public abstract class InMemoryBaseRepository<TEntity> : BaseRepository<TEntity>
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.Where(predicate).CountAsync();
|
||||
var count = await _dbSet
|
||||
.Where(predicate)
|
||||
.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Where(predicate)
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -100,14 +102,16 @@ public abstract class InMemoryBaseRepository<TEntity> : BaseRepository<TEntity>
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.Where(predicate).CountAsync();
|
||||
var count = await _dbSet
|
||||
.Where(predicate)
|
||||
.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Where(predicate)
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.Include(includeSelector)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
|
@ -73,7 +73,7 @@ public sealed class PostgreSqlUnitOfWork : UnitOfWork
|
||||
|
||||
public async Task<int> SaveAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return await _dbContext.SaveChangesAsync();
|
||||
return await _dbContext.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -28,7 +28,7 @@ public abstract class PostgreSqlBaseRepository<TEntity> : BaseRepository<TEntity
|
||||
Expression<Func<TEntity, bool>> predicate,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return await _dbSet.SingleOrDefaultAsync(predicate);
|
||||
return await _dbSet.SingleOrDefaultAsync(predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<TEntity?> GetOneAsync(
|
||||
@ -36,22 +36,21 @@ public abstract class PostgreSqlBaseRepository<TEntity> : BaseRepository<TEntity
|
||||
Expression<Func<TEntity, object>> includeSelector,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return
|
||||
await _dbSet
|
||||
.Include(includeSelector)
|
||||
.SingleOrDefaultAsync(predicate);
|
||||
return await _dbSet
|
||||
.Include(includeSelector)
|
||||
.SingleOrDefaultAsync(predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<PaginatedList<TEntity>> GetPageAsync(
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.CountAsync();
|
||||
var count = await _dbSet.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -63,13 +62,13 @@ public abstract class PostgreSqlBaseRepository<TEntity> : BaseRepository<TEntity
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.CountAsync();
|
||||
var count = await _dbSet.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.Include(includeSelector)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -81,13 +80,15 @@ public abstract class PostgreSqlBaseRepository<TEntity> : BaseRepository<TEntity
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.Where(predicate).CountAsync();
|
||||
var count = await _dbSet
|
||||
.Where(predicate)
|
||||
.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Where(predicate)
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -100,14 +101,16 @@ public abstract class PostgreSqlBaseRepository<TEntity> : BaseRepository<TEntity
|
||||
int pageNumber, int pageSize,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var count = await _dbSet.Where(predicate).CountAsync();
|
||||
var count = await _dbSet
|
||||
.Where(predicate)
|
||||
.CountAsync(cancellationToken);
|
||||
|
||||
var entities =
|
||||
await _dbSet
|
||||
.Where(predicate)
|
||||
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
|
||||
.Include(includeSelector)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new PaginatedList<TEntity>(
|
||||
entities, count,
|
||||
@ -129,5 +132,4 @@ public abstract class PostgreSqlBaseRepository<TEntity> : BaseRepository<TEntity
|
||||
_dbSet.Remove(entity);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user