Browse Source
* Updating repositories and specification version Need to fix broken tests * removing test that would just be testing mocked result now * Refactored from IAsyncRepository and removed it. Tests pass. * Update packagesmain
committed by
GitHub
39 changed files with 281 additions and 289 deletions
@ -1,21 +0,0 @@ |
|||
using Ardalis.Specification; |
|||
using Microsoft.eShopWeb.ApplicationCore.Entities; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces |
|||
{ |
|||
public interface IAsyncRepository<T> where T : BaseEntity, IAggregateRoot |
|||
{ |
|||
Task<T> GetByIdAsync(int id, CancellationToken cancellationToken = default); |
|||
Task<IReadOnlyList<T>> ListAllAsync(CancellationToken cancellationToken = default); |
|||
Task<IReadOnlyList<T>> ListAsync(ISpecification<T> spec, CancellationToken cancellationToken = default); |
|||
Task<T> AddAsync(T entity, CancellationToken cancellationToken = default); |
|||
Task UpdateAsync(T entity, CancellationToken cancellationToken = default); |
|||
Task DeleteAsync(T entity, CancellationToken cancellationToken = default); |
|||
Task<int> CountAsync(ISpecification<T> spec, CancellationToken cancellationToken = default); |
|||
Task<T> FirstAsync(ISpecification<T> spec, CancellationToken cancellationToken = default); |
|||
Task<T> FirstOrDefaultAsync(ISpecification<T> spec, CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
using Ardalis.Specification; |
|||
|
|||
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces |
|||
{ |
|||
public interface IReadRepository<T> : IReadRepositoryBase<T> where T : class, IAggregateRoot |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
using Ardalis.Specification; |
|||
|
|||
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces |
|||
{ |
|||
public interface IRepository<T> : IRepositoryBase<T> where T : class, IAggregateRoot |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Ardalis.Specification; |
|||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; |
|||
|
|||
namespace Microsoft.eShopWeb.ApplicationCore.Specifications |
|||
{ |
|||
public class OrderWithItemsByIdSpec : Specification<Order>, ISingleResultSpecification |
|||
{ |
|||
public OrderWithItemsByIdSpec(int orderId) |
|||
{ |
|||
Query |
|||
.Where(order => order.Id == orderId) |
|||
.Include(o => o.OrderItems) |
|||
.ThenInclude(i => i.ItemOrdered); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue