C
C#β€’7mo ago
πŸ™ˆ

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
sneki
snekiβ€’7mo ago
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/
Pobiega
Pobiegaβ€’7mo ago
Is it strict MVC with no client side code, or is there blazor/javascript involved?
πŸ™ˆ
πŸ™ˆβ€’7mo ago
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
Pobiega
Pobiegaβ€’7mo ago
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
πŸ™ˆ
πŸ™ˆβ€’7mo ago
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.
Pobiega
Pobiegaβ€’7mo ago
sure.
πŸ™ˆ
πŸ™ˆβ€’7mo ago
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
Pobiega
Pobiegaβ€’7mo ago
Do you understand how HTTP works? like, the basics of what a request looks like?
πŸ™ˆ
πŸ™ˆβ€’7mo ago
I sorta get post and get But have been using the built in entity framework views I will learn more about that
Pobiega
Pobiegaβ€’7mo ago
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,
πŸ™ˆ
πŸ™ˆβ€’7mo ago
Ok however we probably want it to open a cart right
Pobiega
Pobiegaβ€’7mo ago
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?
πŸ™ˆ
πŸ™ˆβ€’7mo ago
I mean like a cart view ya With the product the user picked right
Pobiega
Pobiegaβ€’7mo ago
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"
πŸ™ˆ
πŸ™ˆβ€’7mo ago
Ok I see Makes sense
Pobiega
Pobiegaβ€’7mo ago
maybe just show the cart in a side-bar instead?
πŸ™ˆ
πŸ™ˆβ€’7mo ago
Yup Make sense For this bit do I sue @htmlaction or a form
Pobiega
Pobiegaβ€’7mo ago
either or
πŸ™ˆ
πŸ™ˆβ€’7mo ago
Ok and I pass in the product Id
MODiX
MODiXβ€’7mo ago
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.
Pobiega
Pobiegaβ€’7mo ago
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
πŸ™ˆ
πŸ™ˆβ€’7mo ago
Ok so this is a post action I assume As we are posting somthing
Pobiega
Pobiegaβ€’7mo ago
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
πŸ™ˆ
πŸ™ˆβ€’7mo ago
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
Pobiega
Pobiegaβ€’7mo ago
no
sneki
snekiβ€’7mo ago
@🦍 Tim Coreys courses are very good for beginners
sneki
snekiβ€’7mo ago
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.