using BlazorPolicyAuth.Models.Entities;
using Microsoft.EntityFrameworkCore;

namespace BlazorPolicyAuth.Data;

public class AppDbContext(DbContextOptions dbContextOptions) : DbContext(dbContextOptions)
{

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        // var demoUserAccounts = new UserAccount[]
        // {
        //     new() {Id = 1, Email = "user1", Password = "user1"},
        //     new() {Id = 2, Email = "user2", Password = "user2"},
        //     new() {Id = 3, Email = "user3", Password = "user3"},
        //     new() {Id = 4, Email = "user4", Password = "user4"},
        //     new() {Id = 5, Email = "user5", Password = "user5"},
        // };
        // modelBuilder.Entity<UserAccount>().HasData(demoUserAccounts);
        //
        // var demoUserAccountPolicies = new UserAccountPolicy[]
        // {
        //     /* User 1 Policies */
        //     new() {Id = 1, UserAccountId = 1, UserPolicy = UserPolicy.VIEW_PRODUCT, IsEnabled = false},
        //     new() {Id = 2, UserAccountId = 1, UserPolicy = UserPolicy.ADD_PRODUCT, IsEnabled = false},
        //     new() {Id = 3, UserAccountId = 1, UserPolicy = UserPolicy.EDIT_PRODUCT, IsEnabled = false},
        //     new() {Id = 4, UserAccountId = 1, UserPolicy = UserPolicy.DELETE_PRODUCT, IsEnabled = false},
        //     
        //     /* User 2 Policies */
        //     new() {Id = 5, UserAccountId = 2, UserPolicy = UserPolicy.VIEW_PRODUCT, IsEnabled = true},
        //     new() {Id = 6, UserAccountId = 2, UserPolicy = UserPolicy.ADD_PRODUCT, IsEnabled = false},
        //     new() {Id = 7, UserAccountId = 2, UserPolicy = UserPolicy.EDIT_PRODUCT, IsEnabled = false},
        //     new() {Id = 8, UserAccountId = 2, UserPolicy = UserPolicy.DELETE_PRODUCT, IsEnabled = false},
        //     
        //     /* User 3 Policies */
        //     new() {Id = 9, UserAccountId = 3, UserPolicy = UserPolicy.VIEW_PRODUCT, IsEnabled = true},
        //     new() {Id = 10, UserAccountId = 3, UserPolicy = UserPolicy.ADD_PRODUCT, IsEnabled = true},
        //     new() {Id = 11, UserAccountId = 3, UserPolicy = UserPolicy.EDIT_PRODUCT, IsEnabled = false},
        //     new() {Id = 12, UserAccountId = 3, UserPolicy = UserPolicy.DELETE_PRODUCT, IsEnabled = false},
        //     
        //     /* User 4 Policies */
        //     new() {Id = 13, UserAccountId = 4, UserPolicy = UserPolicy.VIEW_PRODUCT, IsEnabled = true},
        //     new() {Id = 14, UserAccountId = 4, UserPolicy = UserPolicy.ADD_PRODUCT, IsEnabled = true},
        //     new() {Id = 15, UserAccountId = 4, UserPolicy = UserPolicy.EDIT_PRODUCT, IsEnabled = true},
        //     new() {Id = 16, UserAccountId = 4, UserPolicy = UserPolicy.DELETE_PRODUCT, IsEnabled = false},
        //     
        //     /* User 5 Policies */
        //     new() {Id = 17, UserAccountId = 5, UserPolicy = UserPolicy.VIEW_PRODUCT, IsEnabled = true},
        //     new() {Id = 18, UserAccountId = 5, UserPolicy = UserPolicy.ADD_PRODUCT, IsEnabled = true},
        //     new() {Id = 19, UserAccountId = 5, UserPolicy = UserPolicy.EDIT_PRODUCT, IsEnabled = true},
        //     new() {Id = 20, UserAccountId = 5, UserPolicy = UserPolicy.DELETE_PRODUCT, IsEnabled = true},
        // };
        // modelBuilder.Entity<UserAccountPolicy>().HasData(demoUserAccountPolicies);
    }
    
    public DbSet<UserAccount> UserAccounts { get; set; }
    public DbSet<UserAccountPolicy> UserAccountPolicies { get; set; }
}