0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I am not sure if that would work for multiple courses?
So you want to load only the courses that the user has purchased right? In order to do this, I would personally approach it this way. Courses Table : (containing all your courses) User Table (All users) and then a linking table UserCourses and here after each purchase of a course, I would store the CourseId and the UserId. And when you load a view, you could simply only load the courses that have the foreign key of Currently Logged in user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.