Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
This pull request primarily introduces the functionality to remove items from a user's basket across the ApplicationCore and Web layers of the application. It also includes a minor change to the database configuration and some adjustments to the UI layout of the basket page.
src/ApplicationCore/Services/BasketService.cs: Implemented the RemoveItemFromBasket method in the BasketService class. The method retrieves the basket using a BasketWithItemsSpecification, calls the RemoveItem method on the retrieved basket, and then updates the basket in the repository.
src/Web/Pages/Basket/Index.cshtml.cs: Added a new method OnPostRemove to the IndexModel class, which is called when a user clicks the 'Remove' button for an item in their basket. The method calls the RemoveItemFromBasket method on the BasketService and updates the BasketModel.
src/Infrastructure/Dependencies.cs: Changed the useOnlyInMemoryDatabase variable to true in the ConfigureServices method of the Dependencies class. This change means that the application will use an in-memory database by default.
This pull request primarily introduces the functionality to remove items from a user's basket across the
ApplicationCore
andWeb
layers of the application. It also includes a minor change to the database configuration and some adjustments to the UI layout of the basket page.Here are the most important changes:
Functionality to remove items from basket:
src/ApplicationCore/Entities/BasketAggregate/Basket.cs
: Added a new methodRemoveItem
to theBasket
class, which removes an item from the basket given a catalog item ID.src/ApplicationCore/Interfaces/IBasketService.cs
: Added a new methodRemoveItemFromBasket
to theIBasketService
interface, which is expected to remove an item from a user's basket.src/ApplicationCore/Services/BasketService.cs
: Implemented theRemoveItemFromBasket
method in theBasketService
class. The method retrieves the basket using aBasketWithItemsSpecification
, calls theRemoveItem
method on the retrieved basket, and then updates the basket in the repository.src/Web/Pages/Basket/Index.cshtml.cs
: Added a new methodOnPostRemove
to theIndexModel
class, which is called when a user clicks the 'Remove' button for an item in their basket. The method calls theRemoveItemFromBasket
method on theBasketService
and updates theBasketModel
.tests/UnitTests/ApplicationCore/Entities/BasketTests/BasketRemoveItem.cs
: Added a new unit test classBasketRemoveItem
to test theRemoveItem
method in theBasket
class.Minor changes:
src/Infrastructure/Dependencies.cs
: Changed theuseOnlyInMemoryDatabase
variable totrue
in theConfigureServices
method of theDependencies
class. This change means that the application will use an in-memory database by default.UI layout adjustments:
src/Web/Pages/Basket/Index.cshtml
: Made several changes to adjust the layout of the basket page, including adding a 'Remove' button for each item in the basket. [1] [2] [3] [4]src/Web/Pages/Basket/Index.cshtml.cs
: Added a debug log statement in theOnPostUpdate
method.