help
Hi Anybody know anything about asp.net mvc. I am trying to build a cart app and need help with the cart and also adding categories to the products. I am using ef core for the database and tried multiple solutions to get it to work but still doesnβt anybody who knows anything about asp.net mvc please dm me
27 Replies
It's a very important skill in software development to be able to narrow down your problem and describe it to others. Narrow down your problem, then ask very concrete questions. You can post code here: https://gist.github.com/
Is it strict MVC with no client side code, or is there blazor/javascript involved?
Um I dont Know blazor I Jsut want to mainly do most of the work in sever side with c# using mvc using the controllers . I can use and know basics JavaScript but have now idea how to link it all together. I have a database as mentioned using ef core
To answer your question better no blazer but can use Java script
Well, the thing with MVC is thats its a pure-backend framework, which means you are limited to one http request -> one http response
so adding a product to the cart means a full page reload
unless you add in some javascript on the frontend to instead of reloading the entire page, you hit an API endpoint and update the right parts like so
I understand, however since I am a beginner would you think that doing it in mvc would be easier also I want to try and get used to mvc.
This was my plan I have a customer model , order model and order product model and also a product model.
sure.
Thanks π
Ok I then added a controller and view using entry framework option
I did some researchers and learnt I could build a add to cart button by using a @html action and some how passing the id of the product to it or by using a form
Can I please have have some help with this
Do you understand how HTTP works?
like, the basics of what a request looks like?
I sorta get post and get
But have been using the built in entity framework views
I will learn more about that
the most important part is you can only send a single response to a single request.
so your request must contain all the information needed for any actions and results you want to arrive at in the end
for example, when the "add to cart" button is clicked, if you want the user to stay on the current page, you'll need to pass in the information regarding what the current page is,
Ok however we probably want it to open a cart right
the button must somehow trigger a http request. That will be via a link (HTTP Get to an MVC action), or via a form (HTTP Post to an MVC action)
"open a cart" doesnt mean anything
do you mean visually, on the page?
I mean like a cart view ya
With the product the user picked right
I dunno, I'd find it incredibly annoying if I got redirected away from the product page/listing I was on when I clicked "add to cart"
Ok I see
Makes sense
maybe just show the cart in a side-bar instead?
Yup
Make sense
For this bit do I sue @htmlaction or a form
either or
Ok and I pass in the product Id
Pobiega
so your request must contain all the information needed for any actions and results you want to arrive at in the end
Quoted by
<@105026391237480448> from #help (click here)
React with β to remove this embed.
just remember this part
HTTP Get has no body, so you only have the query string to put data in
while HTTP Post allows a body, so you can put any amount of data you need there
Ok so this is a post action I assume
As we are posting somthing
sure
I'd agree that its more like a post than a get, if we want to stick with the intended purposes of the http methods
Ok I will try and implement it now thanks for all the help
Hey bit stuck do you know any good tutorials that will me
no
@π¦ Tim Coreys courses are very good for beginners
https://www.iamtimcorey.com/ , he also has youtube
I Am Tim Corey - World-Class Coding Courses
Learn to think and code like a professional developer from expert developer and online educator, Tim Corey.