简体   繁体   中英

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.

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. However, this seems like a tedious and unrealistic approach.

I currently have four DB entities: Category , Industry , Product , ProductItem .

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. Please suggest any revisions to the database that would help. note: I am using asp.net identity for the users.

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. And then based on the user status, you could load the views.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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