大家好...我是 ASP.NET MVC 的新手。我有一个疑问。 不使用 EF使用MVC razor My Home 控制器类在购物车中添加更多产品
public void AddOrderItem(Int64 ID, int quantity)
{
OrderDO order = (OrderDO)Session["Order"];
order.Items.Add(new OrderItem(ID, quantity));
Session["Order"] = order;
}
}
public class OrderDO
{
private IList<OrderItem> _items;
public OrderDO()
{
this._items = new List<OrderItem>();
}
public IList<OrderItem> Items
{
get { return this._items; }
}
}
public class OrderItem
{
public OrderItem()
{
}
public OrderItem(Int64 ID, int quantity)
{
this.ID= ID;
this.Quantity = quantity;
}
public Int64 ID{ get; set; }
public int Quantity { get; set; }
}
我在产品页面中的脚本是
$(document).ready(function () {
$('#AddToCard').click(function () {
var ProductID = $('#txtproductID').val();
var Quantity = $('#txtQuantity').val();
$.ajax({
type: "POST",
url: '../Home/AddOrderItem',
data: { ID: ProductID, quantity: Quantity },
success: function (data) {
if (data) {
}
}
});
});
在上面的代码中正常工作。我点击购物车按钮,如何获取详细购物清单
public ActionResult Details(int id)
{
OrderDO order = (OrderDO)Session["Order"];
return View();
}