简体   繁体   English

ASP.NET MVC5 和实体框架设计题

[英]ASP.NET MVC5 and Entity Framework design questions

I'm wanting to create a simple E-learning site;我想创建一个简单的电子学习网站; in which you can post education packages, course information, videos and documents.您可以在其中发布教育包、课程信息、视频和文档。 Students would be required to make a one-time payment to get access to it.学生需要一次性付款才能使用它。 I can create the checkout process etc fine, but my problem is assigning that package to the user and then showing that it's already been purchased and enabling how the users could add content to the courses.我可以很好地创建结帐流程等,但我的问题是将 package 分配给用户,然后显示它已被购买并启用用户如何向课程添加内容。

I have been thinking that there would be different areas for this, eg when the user does a successful purchase they would be assigned a role and then asp.net identity can show the correct views.我一直认为这会有不同的领域,例如,当用户成功购买时,他们将被分配一个角色,然后 asp.net 身份可以显示正确的视图。 However, this seems like a tedious and unrealistic approach.然而,这似乎是一种乏味且不切实际的方法。

I currently have four DB entities: Category , Industry , Product , ProductItem .我目前有四个数据库实体: CategoryIndustryProductProductItem

Category类别

    public class Category
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        public string Title { get; set; }
    }

Industry行业

    public class Industry
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [MaxLength(55)]
        [Display(Name = "Industry")]
        public string Title { get; set; }
    }

Product产品

    public class Product
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Required]
        [Display(Name = "Product Name")]
        [MaxLength(55)]
        public string Name { get; set; }

        [Required]
        [MaxLength(255)]
        public string Description { get; set; }

        [Required]
        [Range(0, 2000)]
        public decimal Price { get; set; }

        public string Image { get; set; }

        [Display(Name = "Industry")]
        public int IndustryId { get; set; }

        public Industry Industry { get; set; }
    }

Product Item产品项目

    public class ProductItem
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        public string Title { get; set; }

        [Display(Name = "Course")]
        public int ProductId { get; set; }

        public Product Product { get; set; }

        [Display(Name = "Category")]
        public int CategoryId { get; set; }

        public Category Category { get; set; }
    }

I am using the Product class as the initial course view, and the ProductItem as the course contents that users can access.我使用Product class 作为初始课程视图,使用ProductItem作为用户可以访问的课程内容。 Please suggest any revisions to the database that would help.请建议对数据库有帮助的任何修订。 note: I am using asp.net identity for the users.注意:我为用户使用 asp.net 身份。

I couldn't comment due to low rep, but how about such solution: you could add a new column to "User" table "IsPremium" as bool or however you want to call it, when the purchase is made, you will toggle that value to true.由于代表率低,我无法发表评论,但是这样的解决方案怎么样:您可以将新列添加到“用户”表“IsPremium”作为布尔值,或者您想调用它,当购买时,您将切换它值为真。 And then based on the user status, you could load the views.然后根据用户状态,您可以加载视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM