Skip to content

Commit

Permalink
Add CancellationToken to repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav Horbachov committed Jul 22, 2023
1 parent 86b6a89 commit c385ec4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/Inventory.Domain/Products/IProductsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface IProductsRepository
Task<Product?> GetByIdAsync(ProductId id, CancellationToken cancellationToken);

Task DeleteByIdAsync(ProductId id, CancellationToken cancellationToken);

Task DeleteManyByIdAsync(ProductId productId, CancellationToken cancellationToken);
}
2 changes: 1 addition & 1 deletion src/Inventory.Domain/Warehouses/IWarehouseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Inventory.Persistence.Database.Repositories;

public interface IWarehouseRepository
public interface IWarehousesRepository
{
Task<Warehouse> GetByIdAsync(ProductId productId, CancellationToken cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Inventory.Infrastructure.Services.DataAccess;

internal interface ISnapshotsRepository
{
Task<Snapshot> GetLatestAsync(ProductId productId);
Task<Snapshot> GetLatestAsync(ProductId productId, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public WarehouseAccountantService(IWarehouseRepository warehouseRepository, ISna
_snapshotsRepository = snapshotsRepository;
}

public async Task<IWarehouseAccountant> GetActualProductQuantityAccountant(ProductId productId)
public async Task<IWarehouseAccountant> GetActualProductQuantityAccountant(ProductId productId, CancellationToken cancellationToken)
{
var snapshot = await _snapshotsRepository.GetLatestAsync(productId);
var warehouse = await _warehouseRepository.GetByIdAsync(productId, snapshot);
var snapshot = await _snapshotsRepository.GetLatestAsync(productId, cancellationToken);
var warehouse = await _warehouseRepository.GetByIdAsync(productId, snapshot, cancellationToken);

return new ActualProductQuantityProjection(warehouse.DomainEvents, snapshot);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace Inventory.Persistence.Database.Repositories;

public interface IWarehouseRepository
{
Task<Warehouse> GetByIdAsync(ProductId productId, Snapshot snapshot);
Task<Warehouse> GetByIdAsync(ProductId productId, Snapshot snapshot, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Inventory.Persistence.Database.Repositories;

internal sealed class WarehouseRepository : IWarehouseRepository
{
public Task<Warehouse> GetByIdAsync(ProductId productId, Snapshot snapshot)
public Task<Warehouse> GetByIdAsync(ProductId productId, Snapshot snapshot, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
Expand Down

0 comments on commit c385ec4

Please sign in to comment.