From ba9aea29bdb94eca6fc697c4f42aaa431768c757 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Sat, 13 Feb 2021 10:50:31 -0500 Subject: [PATCH] Update to latest Endpoints package and fix breaking changes (#506) --- .../Entities/BasketAggregate/Basket.cs | 60 +++++++++---------- src/BlazorShared/BlazorShared.csproj | 1 + src/PublicApi/AuthEndpoints/Authenticate.cs | 4 +- src/PublicApi/CatalogBrandEndpoints/List.cs | 4 +- src/PublicApi/CatalogItemEndpoints/Create.cs | 4 +- src/PublicApi/CatalogItemEndpoints/Delete.cs | 4 +- src/PublicApi/CatalogItemEndpoints/GetById.cs | 4 +- .../CatalogItemEndpoints/ListPaged.cs | 4 +- src/PublicApi/CatalogItemEndpoints/Update.cs | 4 +- src/PublicApi/CatalogTypeEndpoints/List.cs | 4 +- src/PublicApi/PublicApi.csproj | 2 +- 11 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/ApplicationCore/Entities/BasketAggregate/Basket.cs b/src/ApplicationCore/Entities/BasketAggregate/Basket.cs index 94c803e..be07bfe 100644 --- a/src/ApplicationCore/Entities/BasketAggregate/Basket.cs +++ b/src/ApplicationCore/Entities/BasketAggregate/Basket.cs @@ -1,39 +1,39 @@ -using Microsoft.eShopWeb.ApplicationCore.Interfaces; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate -{ - public class Basket : BaseEntity, IAggregateRoot - { - public string BuyerId { get; private set; } - private readonly List _items = new List(); - public IReadOnlyCollection Items => _items.AsReadOnly(); - +using Microsoft.eShopWeb.ApplicationCore.Interfaces; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate +{ + public class Basket : BaseEntity, IAggregateRoot + { + public string BuyerId { get; private set; } + private readonly List _items = new List(); + public IReadOnlyCollection Items => _items.AsReadOnly(); + public Basket(string buyerId) { BuyerId = buyerId; - } - - public void AddItem(int catalogItemId, decimal unitPrice, int quantity = 1) - { - if (!Items.Any(i => i.CatalogItemId == catalogItemId)) - { - _items.Add(new BasketItem(catalogItemId, quantity, unitPrice)); - return; - } - var existingItem = Items.FirstOrDefault(i => i.CatalogItemId == catalogItemId); - existingItem.AddQuantity(quantity); - } - + } + + public void AddItem(int catalogItemId, decimal unitPrice, int quantity = 1) + { + if (!Items.Any(i => i.CatalogItemId == catalogItemId)) + { + _items.Add(new BasketItem(catalogItemId, quantity, unitPrice)); + return; + } + var existingItem = Items.FirstOrDefault(i => i.CatalogItemId == catalogItemId); + existingItem.AddQuantity(quantity); + } + public void RemoveEmptyItems() { _items.RemoveAll(i => i.Quantity == 0); - } - + } + public void SetNewBuyerId(string buyerId) { BuyerId = buyerId; - } - } -} + } + } +} diff --git a/src/BlazorShared/BlazorShared.csproj b/src/BlazorShared/BlazorShared.csproj index 6e1baa0..9ddef88 100644 --- a/src/BlazorShared/BlazorShared.csproj +++ b/src/BlazorShared/BlazorShared.csproj @@ -8,6 +8,7 @@ + diff --git a/src/PublicApi/AuthEndpoints/Authenticate.cs b/src/PublicApi/AuthEndpoints/Authenticate.cs index f2dfcb8..6a79af6 100644 --- a/src/PublicApi/AuthEndpoints/Authenticate.cs +++ b/src/PublicApi/AuthEndpoints/Authenticate.cs @@ -9,7 +9,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.AuthEndpoints { - public class Authenticate : BaseAsyncEndpoint + public class Authenticate : BaseAsyncEndpoint + .WithRequest + .WithResponse { private readonly SignInManager _signInManager; private readonly ITokenClaimsService _tokenClaimsService; diff --git a/src/PublicApi/CatalogBrandEndpoints/List.cs b/src/PublicApi/CatalogBrandEndpoints/List.cs index 197e8ab..585ea2c 100644 --- a/src/PublicApi/CatalogBrandEndpoints/List.cs +++ b/src/PublicApi/CatalogBrandEndpoints/List.cs @@ -10,7 +10,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints { - public class List : BaseAsyncEndpoint + public class List : BaseAsyncEndpoint + .WithoutRequest + .WithResponse { private readonly IAsyncRepository _catalogBrandRepository; private readonly IMapper _mapper; diff --git a/src/PublicApi/CatalogItemEndpoints/Create.cs b/src/PublicApi/CatalogItemEndpoints/Create.cs index c1c1068..ef35707 100644 --- a/src/PublicApi/CatalogItemEndpoints/Create.cs +++ b/src/PublicApi/CatalogItemEndpoints/Create.cs @@ -13,7 +13,9 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints { [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] - public class Create : BaseAsyncEndpoint + public class Create : BaseAsyncEndpoint + .WithRequest + .WithResponse { private readonly IAsyncRepository _itemRepository; private readonly IUriComposer _uriComposer; diff --git a/src/PublicApi/CatalogItemEndpoints/Delete.cs b/src/PublicApi/CatalogItemEndpoints/Delete.cs index e5750a3..f7f4a97 100644 --- a/src/PublicApi/CatalogItemEndpoints/Delete.cs +++ b/src/PublicApi/CatalogItemEndpoints/Delete.cs @@ -11,7 +11,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints { [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] - public class Delete : BaseAsyncEndpoint + public class Delete : BaseAsyncEndpoint + .WithRequest + .WithResponse { private readonly IAsyncRepository _itemRepository; diff --git a/src/PublicApi/CatalogItemEndpoints/GetById.cs b/src/PublicApi/CatalogItemEndpoints/GetById.cs index 5c733ee..3b34958 100644 --- a/src/PublicApi/CatalogItemEndpoints/GetById.cs +++ b/src/PublicApi/CatalogItemEndpoints/GetById.cs @@ -8,7 +8,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints { - public class GetById : BaseAsyncEndpoint + public class GetById : BaseAsyncEndpoint + .WithRequest + .WithResponse { private readonly IAsyncRepository _itemRepository; private readonly IUriComposer _uriComposer; diff --git a/src/PublicApi/CatalogItemEndpoints/ListPaged.cs b/src/PublicApi/CatalogItemEndpoints/ListPaged.cs index 8c8759d..75d1bd2 100644 --- a/src/PublicApi/CatalogItemEndpoints/ListPaged.cs +++ b/src/PublicApi/CatalogItemEndpoints/ListPaged.cs @@ -12,7 +12,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints { - public class ListPaged : BaseAsyncEndpoint + public class ListPaged : BaseAsyncEndpoint + .WithRequest + .WithResponse { private readonly IAsyncRepository _itemRepository; private readonly IUriComposer _uriComposer; diff --git a/src/PublicApi/CatalogItemEndpoints/Update.cs b/src/PublicApi/CatalogItemEndpoints/Update.cs index c24bfb6..991c72e 100644 --- a/src/PublicApi/CatalogItemEndpoints/Update.cs +++ b/src/PublicApi/CatalogItemEndpoints/Update.cs @@ -12,7 +12,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints { [Authorize(Roles = BlazorShared.Authorization.Constants.Roles.ADMINISTRATORS, AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] - public class Update : BaseAsyncEndpoint + public class Update : BaseAsyncEndpoint + .WithRequest + .WithResponse { private readonly IAsyncRepository _itemRepository; private readonly IUriComposer _uriComposer; diff --git a/src/PublicApi/CatalogTypeEndpoints/List.cs b/src/PublicApi/CatalogTypeEndpoints/List.cs index d2f4e32..6621bf4 100644 --- a/src/PublicApi/CatalogTypeEndpoints/List.cs +++ b/src/PublicApi/CatalogTypeEndpoints/List.cs @@ -10,7 +10,9 @@ using System.Threading.Tasks; namespace Microsoft.eShopWeb.PublicApi.CatalogTypeEndpoints { - public class List : BaseAsyncEndpoint + public class List : BaseAsyncEndpoint + .WithoutRequest + .WithResponse { private readonly IAsyncRepository _catalogTypeRepository; private readonly IMapper _mapper; diff --git a/src/PublicApi/PublicApi.csproj b/src/PublicApi/PublicApi.csproj index 0c83d1e..9e38065 100644 --- a/src/PublicApi/PublicApi.csproj +++ b/src/PublicApi/PublicApi.csproj @@ -9,7 +9,7 @@ - +