Code2Gether-Discord / Congo

Generic web store learning project that consists of three ASP.NET Core projects
https://code2gether-congo.azurewebsites.net/
11 stars 2 forks source link

As a customer I want to be able to add products to a cart so that I can purchase multiple items at once #69

Open valincius opened 2 years ago

valincius commented 2 years ago

Given I am a customer When I view the product list Then I can choose a quantity (1-99) of any product Then I can add multiple products to a cart

ofu997 commented 2 years ago

I can try this issue, but currently getting this: SocketException: No connection could be made because the target machine actively refused it.

HttpRequestException: No connection could be made because the target machine actively refused it. (localhost:44388)

valincius commented 2 years ago

You need to run the front end and api projects at the same time. You can do so by setting multiple startup projects in VS or by launching both projects manually. @ofu997

ofu997 commented 2 years ago

Tried starting a nonasync method to handle a cart object, which resulted an object instance error since the page expects there to be a Model.Products property. Is there a way to include multiple page-handlers in the same form, since this would go with the existing OnPostPurchase ?

valincius commented 2 years ago

That OnPostPurchase was Ok because we the user didn’t need to stay on the same page. We want them to stay on the products page now, so you’d probably want to use JS (fetch) to send the request instead of posting it how we’re doing now.

ofu997 commented 2 years ago

https://learningprogramming.net/net/asp-net-core-razor-pages/build-shopping-cart-with-session-in-asp-net-core-razor-pages/

An approach I found that uses CartItems as the model behind a Cart page. Downside is that selecting the quantity of items will not be on the Products page.

valincius commented 2 years ago

Well we will want something like that for the cart page, but here we want this similar functionality on the products page. If you need some guidance you can PM me on discord and I can try walking you through what’s needed here. Should be relatively simple. @ofu997