微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试在 asp.net mvc5

如何解决尝试在 asp.net mvc5

我首先尝试使用实体框架代码制作电子商务网站,但篮子有问题我不需要添加银行账户或任何类型的付款方式是货到付款我准备好图标作为按钮

<dd>
                        @Html.ActionLink("Add","Basket",new { id = this.Model.Id },new { @class = "btn btn-primary"})
                    </dd>

一旦点击它就会激活动作方法

public ActionResult Basket(int Id)
    {
        PB.basket(Id);
        return View();
    }

witch 会激活一个叫做 bag 的方法

public void basket(int Id)
    {
        List<Basket> bst = new List<Basket>();
        var user = HttpContext.Current.Session.SessionID;
        var prd = db.Products.Where(p => p.Id == Id).FirstOrDefault();
        bst.Add(new Basket()
        {
            Price = prd.Price,ProductId = prd.Id,Count = 1,}) ;
    }

这里是创建数据库的类 使用身份

  public class users
    {
        public string Id { get; set; }
        public string UserName { get; set; }
        public string Email { get; set; }
        public string Address { get; set; }
        public string PhoneNumber { get; set; }
    }

 public class Product
    {
        public int Id { get; set; }
        [display(Name = "Product Name")]
        public string ProductName { get; set; }
        [DataType(DataType.ImageUrl)]
        public string Image { get; set; }
        public string Category { get; set; }
        public double Price { get; set; }
        [DataType(DataType.Text)]
        public string Description { get; set; }
        [NotMapped]
        public HttpPostedFileBase ImageFile { get; set; }
    }
 public class Basket
    {
        public int Id { get; set; }
        public int ProductId { get; set; }
        public int Count { get; set; }
        public double Price { get; set; }
        public ApplicationUser user { get; set; }
        public Product Product { get; set; }
        public ICollection<Product> products { get; set; }
        public ICollection<ApplicationUser> users { get; set; }
    }

请帮忙

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。