Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Strategy for Shopping Cart (.Net Core 3.1 MVC)

$
0
0

Hi. I'm very new coding, so the most practical & easy solution will be fine for my by now.

I'm doing a very vanilla net core 3.1 mvc academic project and I need to implement a shopping cart.

My involved Models are:

  • Order, that contains a collection of
  • LineOrder which is linked with one
  • Instrument (an Instrument can be linked to many LineOrders on differents Orders).

My Uses Cases are 2:

  • In the Homepage you can "Add to Cart" an Instrument, which has to be added to cart with the quantity of 1 & default attributes.
  • In the Instrument/Details you can select different product attributes and the quantity of items and then "Add to Cart".

In both cases I suppose I have to use ajax requests.

If the user is authenticated the cart has to be loaded (If the purchase isn't completed). I guess I will need some init rutine to load or create the cart.

On the navbar I have a counter that has to show the nº of items in the cart.

I see at least 3 differents aproaches but I don't know which one could I use( I accept new ones):

  1. Cart logic inside Order/Details Controller & custom methods(add,remove to cart, load etc). A cart would be an Order withStatus property as "Cart" until payment is made whose Status changes to "processing".
  2. Cart logic on dedicated CartController. I would only  use a CartDetails View, but I would make POST request to it's methods.
  3. Cart Class(that you injects at required place) works with Order, LineOrders & Instrument Models and I don't know if use Interface like CartService. (very few experience with that).

I remember that I don't have so much experience (I messed up beyond scaffolded Model > Controller > View) and the simplest and closest solution to the vanilla project, will be fine for me. 

Thanks in advance.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>