Browse Source

Update to latest Endpoints package and fix breaking changes (#506)

main
Steve Smith 5 years ago
committed by GitHub
parent
commit
ba9aea29bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      src/ApplicationCore/Entities/BasketAggregate/Basket.cs
  2. 1
      src/BlazorShared/BlazorShared.csproj
  3. 4
      src/PublicApi/AuthEndpoints/Authenticate.cs
  4. 4
      src/PublicApi/CatalogBrandEndpoints/List.cs
  5. 4
      src/PublicApi/CatalogItemEndpoints/Create.cs
  6. 4
      src/PublicApi/CatalogItemEndpoints/Delete.cs
  7. 4
      src/PublicApi/CatalogItemEndpoints/GetById.cs
  8. 4
      src/PublicApi/CatalogItemEndpoints/ListPaged.cs
  9. 4
      src/PublicApi/CatalogItemEndpoints/Update.cs
  10. 4
      src/PublicApi/CatalogTypeEndpoints/List.cs
  11. 2
      src/PublicApi/PublicApi.csproj

60
src/ApplicationCore/Entities/BasketAggregate/Basket.cs

@ -1,39 +1,39 @@
using Microsoft.eShopWeb.ApplicationCore.Interfaces; using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate
{ {
public class Basket : BaseEntity, IAggregateRoot public class Basket : BaseEntity, IAggregateRoot
{ {
public string BuyerId { get; private set; } public string BuyerId { get; private set; }
private readonly List<BasketItem> _items = new List<BasketItem>(); private readonly List<BasketItem> _items = new List<BasketItem>();
public IReadOnlyCollection<BasketItem> Items => _items.AsReadOnly(); public IReadOnlyCollection<BasketItem> Items => _items.AsReadOnly();
public Basket(string buyerId) public Basket(string buyerId)
{ {
BuyerId = buyerId; BuyerId = buyerId;
} }
public void AddItem(int catalogItemId, decimal unitPrice, int quantity = 1) public void AddItem(int catalogItemId, decimal unitPrice, int quantity = 1)
{ {
if (!Items.Any(i => i.CatalogItemId == catalogItemId)) if (!Items.Any(i => i.CatalogItemId == catalogItemId))
{ {
_items.Add(new BasketItem(catalogItemId, quantity, unitPrice)); _items.Add(new BasketItem(catalogItemId, quantity, unitPrice));
return; return;
} }
var existingItem = Items.FirstOrDefault(i => i.CatalogItemId == catalogItemId); var existingItem = Items.FirstOrDefault(i => i.CatalogItemId == catalogItemId);
existingItem.AddQuantity(quantity); existingItem.AddQuantity(quantity);
} }
public void RemoveEmptyItems() public void RemoveEmptyItems()
{ {
_items.RemoveAll(i => i.Quantity == 0); _items.RemoveAll(i => i.Quantity == 0);
} }
public void SetNewBuyerId(string buyerId) public void SetNewBuyerId(string buyerId)
{ {
BuyerId = buyerId; BuyerId = buyerId;
} }
} }
} }

1
src/BlazorShared/BlazorShared.csproj

@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="BlazorInputFile" Version="0.2.0" /> <PackageReference Include="BlazorInputFile" Version="0.2.0" />
<PackageReference Include="FluentValidation" Version="9.3.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

4
src/PublicApi/AuthEndpoints/Authenticate.cs

@ -9,7 +9,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.AuthEndpoints namespace Microsoft.eShopWeb.PublicApi.AuthEndpoints
{ {
public class Authenticate : BaseAsyncEndpoint<AuthenticateRequest, AuthenticateResponse> public class Authenticate : BaseAsyncEndpoint
.WithRequest<AuthenticateRequest>
.WithResponse<AuthenticateResponse>
{ {
private readonly SignInManager<ApplicationUser> _signInManager; private readonly SignInManager<ApplicationUser> _signInManager;
private readonly ITokenClaimsService _tokenClaimsService; private readonly ITokenClaimsService _tokenClaimsService;

4
src/PublicApi/CatalogBrandEndpoints/List.cs

@ -10,7 +10,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints
{ {
public class List : BaseAsyncEndpoint<ListCatalogBrandsResponse> public class List : BaseAsyncEndpoint
.WithoutRequest
.WithResponse<ListCatalogBrandsResponse>
{ {
private readonly IAsyncRepository<CatalogBrand> _catalogBrandRepository; private readonly IAsyncRepository<CatalogBrand> _catalogBrandRepository;
private readonly IMapper _mapper; private readonly IMapper _mapper;

4
src/PublicApi/CatalogItemEndpoints/Create.cs

@ -13,7 +13,9 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{ {
[Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class Create : BaseAsyncEndpoint<CreateCatalogItemRequest, CreateCatalogItemResponse> public class Create : BaseAsyncEndpoint
.WithRequest<CreateCatalogItemRequest>
.WithResponse<CreateCatalogItemResponse>
{ {
private readonly IAsyncRepository<CatalogItem> _itemRepository; private readonly IAsyncRepository<CatalogItem> _itemRepository;
private readonly IUriComposer _uriComposer; private readonly IUriComposer _uriComposer;

4
src/PublicApi/CatalogItemEndpoints/Delete.cs

@ -11,7 +11,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{ {
[Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class Delete : BaseAsyncEndpoint<DeleteCatalogItemRequest, DeleteCatalogItemResponse> public class Delete : BaseAsyncEndpoint
.WithRequest<DeleteCatalogItemRequest>
.WithResponse<DeleteCatalogItemResponse>
{ {
private readonly IAsyncRepository<CatalogItem> _itemRepository; private readonly IAsyncRepository<CatalogItem> _itemRepository;

4
src/PublicApi/CatalogItemEndpoints/GetById.cs

@ -8,7 +8,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{ {
public class GetById : BaseAsyncEndpoint<GetByIdCatalogItemRequest, GetByIdCatalogItemResponse> public class GetById : BaseAsyncEndpoint
.WithRequest<GetByIdCatalogItemRequest>
.WithResponse<GetByIdCatalogItemResponse>
{ {
private readonly IAsyncRepository<CatalogItem> _itemRepository; private readonly IAsyncRepository<CatalogItem> _itemRepository;
private readonly IUriComposer _uriComposer; private readonly IUriComposer _uriComposer;

4
src/PublicApi/CatalogItemEndpoints/ListPaged.cs

@ -12,7 +12,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{ {
public class ListPaged : BaseAsyncEndpoint<ListPagedCatalogItemRequest, ListPagedCatalogItemResponse> public class ListPaged : BaseAsyncEndpoint
.WithRequest<ListPagedCatalogItemRequest>
.WithResponse<ListPagedCatalogItemResponse>
{ {
private readonly IAsyncRepository<CatalogItem> _itemRepository; private readonly IAsyncRepository<CatalogItem> _itemRepository;
private readonly IUriComposer _uriComposer; private readonly IUriComposer _uriComposer;

4
src/PublicApi/CatalogItemEndpoints/Update.cs

@ -12,7 +12,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{ {
[Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class Update : BaseAsyncEndpoint<UpdateCatalogItemRequest, UpdateCatalogItemResponse> public class Update : BaseAsyncEndpoint
.WithRequest<UpdateCatalogItemRequest>
.WithResponse<UpdateCatalogItemResponse>
{ {
private readonly IAsyncRepository<CatalogItem> _itemRepository; private readonly IAsyncRepository<CatalogItem> _itemRepository;
private readonly IUriComposer _uriComposer; private readonly IUriComposer _uriComposer;

4
src/PublicApi/CatalogTypeEndpoints/List.cs

@ -10,7 +10,9 @@ using System.Threading.Tasks;
namespace Microsoft.eShopWeb.PublicApi.CatalogTypeEndpoints namespace Microsoft.eShopWeb.PublicApi.CatalogTypeEndpoints
{ {
public class List : BaseAsyncEndpoint<ListCatalogTypesResponse> public class List : BaseAsyncEndpoint
.WithoutRequest
.WithResponse<ListCatalogTypesResponse>
{ {
private readonly IAsyncRepository<CatalogType> _catalogTypeRepository; private readonly IAsyncRepository<CatalogType> _catalogTypeRepository;
private readonly IMapper _mapper; private readonly IMapper _mapper;

2
src/PublicApi/PublicApi.csproj

@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Ardalis.ApiEndpoints" Version="2.0.0" /> <PackageReference Include="Ardalis.ApiEndpoints" Version="3.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
<PackageReference Include="MediatR" Version="9.0.0" /> <PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" /> <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />

Loading…
Cancel
Save