I am 100% new to ASP.NET and I've been working on this problem for a few weeks. I'm trying to have a very barebones website that when loaded will prompt the user for their dessert preference. If they like cakes, the website will display cake photos, if they like jelly, it will display jelly.
My first thought was to start with the SQL database. It has two tables, Jelly
and Cakes
, both have the same format for columns.
An integer for id
, a varchar for name
and a binarydata for storing the image.
Then I created the website on ASP.NET. I started by generating a ASP.NET Web App (MVC) in Microsoft Visual Studio. I tried to create a model class called Dessert
that would create a dataset of either Jelly
or Cakes
dependent on what the user choose but I couldn't figure out how exactly to create that.
I went online and read some documentation and apparently ASP.NET can auto generate a SQL database based on your model? I toyed around with creating different models, trying to connect the model to my SQL database, auto-generating the SQL database with ASP.NET but I'll be honest and say, I haven't got a clue what I'm doing.
My initial feeling was to create a model, have some sort of starting page that asks the user their preference, the Dessert
class gets made based on the user's preference and the webpages are dynamically displayed with whatever their preference was.
Any help on this would be appreciated. Even if it's just a link to a resource that can help me.
Thanks.
CodePudding user response:
This involve many steps --
- You create the db
- Create Web Project
- Add Option to connect with Database, you can use (Entity Framework, Plain ADO.NET, Dapper)
- Create a db class to make methods that call db
- Create model class to hold data returned from db
- Create controller and call db class to get data and pass it to view
- Create MVC view to show data and capture user intergation
For you use case I allready prepared some code and database, please look into this repo -- https://github.com/mataprasad/MyDesserts