需要帮助在MVC中创建购物车?
我需要帮助创建一个显示披萨大小和浇头的视图。我在SQL表中都得到了它们。需要使用复选框选择它们。然后,当他们完成披萨的设计时,他们需要按一个按钮,将按钮重定向到结帐页面,在那里他们可以查看他们的订单。
I need help creating a view that will display the pizza size and the toppings. I got both in a SQL table. They need to be selected by using a checkbox. Then when they are done designing the pizza, they need to press a button that will redirect them to the checkout page where they can review their order.
create table tblIntgredients
(
dID int identity(1,1) primary key,
dIngredient varchar (25),
dCost decimal (25),
)
go
create table tblPizzasize
(
dID int identity(1,1)primary key,
dSize varchar(15),
dPrice varchar (5),
)
go
现在,我如何在价格中显示成分名称,如何以价格显示尺寸? (得到每张桌子的模型)
然后,我如何制作适合这两种模型的购物车模型?如何将所选商品添加到购物车中以便结帐?如果有人可以帮助我,我将不胜感激。
我尝试过:
我尝试过以下书籍教程和youtube教程,但很难理解,因为它们只做一个表,我需要两个表。有些教程很难理解,因为它们没有解释。或者我很难实现我的代码,就像他们
Now, How can I display the Ingredient name with the price, and how can I display the size with the price?( got a model for each of these tables)
Then, how can I make a shopping cart model that will fit these two models? How can I add the selected items to the cart for checkout? If anyone can help me, it will be much appreciated.
What I have tried:
I tried following book tutorials and youtube tutorials, but they are hard to follow as they only do one table and I need two tables. Some of the tutorials are hard to follow because they don't explain. Or I have a hard time implementing my code like they are
我认为我不太了解你的问题。
假设您有Pizza Entity和Ingredient的模型(POCO类),每个都有一个属性ID。和Pizza实体有一个导航属性添加到其中的成分列表。
所以创建一个模型调用CartItem具有以下属性:
IngredientName
尺寸
价格
点数
然后当点击添加到购物车时,从数据库中获取披萨和配料并使用它们将值提供给CartItem。
I don't think I really understand your questions very well.
Let's assume you have models (POCO classes) for both Pizza Entity and Ingredient, each having a property ID. and the Pizza entity having a navigation property to list of ingredients added to it.
So create a model call it CartItem with the following properties :
IngredientName
Size
Price
Count
Then when the "Add to cart " is clicked get the pizza and the ingredient from the database and use them to supply values into the CartItem.