AppDbContext (Before merging)

PHOTO EMBED

Thu Aug 08 2024 16:02:12 GMT+0000 (Coordinated Universal Time)

Saved by @iamkatmakhafola

using av_motion_api.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.Net.NetworkInformation;
using System.Reflection.Emit;
using System.Security.Claims;
using System.Xml.Linq;

namespace av_motion_api.Data
{
    public class AppDbContext : IdentityDbContext<User, Role, int>

    {
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

        //set tables


        public DbSet<Attendance_List> Attendance_Lists { get; set; }
        public DbSet<Audit_Trail> Audit_Trails { get; set; }
        public DbSet<Booking> Bookings { get; set; }
        public DbSet<Booking_Time_Slot> Booking_Time_Slots { get; set; }
        public DbSet<Cart> Carts { get; set; }
        public DbSet<Cart_Item> Cart_Items { get; set; }
        public DbSet<Contract> Contracts { get; set; }
        public DbSet<Contract_History> Contract_History { get; set; }
        public DbSet<Contract_Type> Contract_Types { get; set; }
        public DbSet<DeletionSettings> DeletionSettings { get; set; }
        public DbSet<Discount> Discounts { get; set; }
        public DbSet<Employee> Employees { get; set; }
        public DbSet<Employee_Type> Employee_Types { get; set; }
        public DbSet<Equipment> Equipment { get; set; }
        public DbSet<Inspection> Inspection { get; set; }
        public DbSet<Inspection_Status> Inspection_Status { get; set; }
        public DbSet<Inspection_Type> Inspection_Type { get; set; }
        public DbSet<Inventory> Inventory { get; set; }
        public DbSet<Lesson_Plan> Lesson_Plans { get; set; }

        public DbSet<Lesson_Plan_Workout> lesson_Plan_Workout { get; set; }

        public DbSet<Member> Members { get; set; }
        public DbSet<Order> Orders { get; set; }
        public DbSet<Order_Line> Order_Lines { get; set; }
        public DbSet<Order_Status> Order_Status { get; set; }
        public DbSet<Outstanding_Payment> Outstanding_Payments { get; set; }
        public DbSet<Owner> Owners { get; set; }
        public DbSet<Payment> Payments { get; set; }
        public DbSet<Payment_Method> Payment_Methods { get; set; }
        public DbSet<Payment_Type> Payment_Types { get; set; }
        public DbSet<Price> Prices { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<Product_Category> Product_Categories { get; set; }
        public DbSet<Received_Supplier_Order> Received_Supplier_Orders { get; set; }
        public DbSet<Received_Supplier_Order_Line> Received_Supplier_Order_Lines { get; set; }
        public DbSet<Report> Reports { get; set; }
        public DbSet<Reward> Rewards { get; set; }

        public DbSet<Role> Roles { get; set; }
        public DbSet<Reward_Member> Reward_Members { get; set; }
        public DbSet<Reward_Type> Reward_Types { get; set; }
        public DbSet<Shift> Shifts { get; set; }
        public DbSet<Supplier> Suppliers { get; set; }
        public DbSet<Supplier_Order> Supplier_Orders { get; set; }
        public DbSet<Supplier_Order_Line> Supplier_Order_Lines { get; set; }
        public DbSet<Time_Slot> Time_Slots { get; set; }

        public DbSet<User> Users { get; set; }
        public DbSet<User_Status> Users_Status{ get; set; }

        public DbSet<User_Type> User_Types { get; set; }
        public DbSet<VAT> VAT { get; set; }

        public DbSet<Wishlist> Wishlists { get; set; }
        public DbSet<Wishlist_Item> Wishlist_Items { get; set; }

        public DbSet<Workout_Category> Workout_Category { get; set; }
        public DbSet<Workout> Workout { get; set; }
  
        public DbSet<Write_Off> Write_Offs { get; set; }



        protected override void OnModelCreating(ModelBuilder builder)
        {
            //Renaming of Default asp Tables
            builder.Entity<User>().ToTable("Users");
            builder.Entity<IdentityUserRole<int>>().ToTable("User_Roles");
            builder.Entity<IdentityUserLogin<int>>().ToTable("User_Logins");
            builder.Entity<Role>().ToTable("Roles");
            builder.Entity<IdentityRoleClaim<int>>().ToTable("Role_Claims");
            builder.Entity<IdentityUserClaim<int>>().ToTable("User_Claims");
            builder.Entity<IdentityUserToken<int>>().ToTable("Tokens");

            //Validation fix for database, specifying coulm types to be type decimal
            // builder.Entity<Contract>()
            //.Property(c => c.Initial_Fee)
            //.HasColumnType("decimal(18, 2)");

            builder.Entity<DeletionSettings>()
            .HasKey(ds => new { ds.DeletionTimeValue, ds.DeletionTimeUnit });

            builder.Entity<DeletionSettings>()
            .Property(ds => ds.DeletionTimeValue)
            .IsRequired();

            builder.Entity<DeletionSettings>()
            .Property(ds => ds.DeletionTimeUnit)
            .IsRequired()
            .HasMaxLength(50);

            builder.Entity<VAT>()
            .Property(v => v.VAT_Percentage)
            .HasColumnType("decimal(18, 2)");

            builder.Entity<Order>()
           .Property(o => o.Total_Price)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Outstanding_Payment>()
           .Property(op => op.Amount_Due)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Outstanding_Payment>()
           .Property(op => op.Late_Fee)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Payment>()
           .Property(pay => pay.Amount)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Price>()
           .Property(pr => pr.Unit_Price)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Product>()
            .Property(p => p.Unit_Price)
            .HasColumnType("decimal(18, 2)"); // Add this line for Unit_Price

            builder.Entity<Product>()
            .Property(p => p.Purchase_Price)
            .HasColumnType("decimal(18, 2)");

            builder.Entity<Supplier_Order>()
           .Property(so => so.Total_Price)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Supplier_Order_Line>()
            .Property(sol => sol.Purchase_Price)
            .HasColumnType("decimal(18, 2)");

            builder.Entity<Supplier_Order_Line>()
            .Property(sol => sol.Unit_Price)
            .HasColumnType("decimal(18, 2)");

            builder.Entity<Discount>()
           .Property(d => d.Discount_Percentage)
           .HasColumnType("decimal(18, 2)");

            builder.Entity<Supplier_Order_Line>()
             .HasOne(s => s.Product)
             .WithMany()
             .HasForeignKey(s => s.Product_ID)
             .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Order_Line>()
           .Property(ol => ol.Unit_Price)
           .HasColumnType("decimal(18,2)");

            //Delete cascade error fix
            //builder.Entity<Payment>()
            //.HasOne(p => p.Payment_Type)
            //.WithMany()
            //.HasForeignKey(p => p.Payment_Type_ID)
            //.OnDelete(DeleteBehavior.NoAction);

            //builder.Entity<Supplier_Order_Line>()
            //.HasOne(s => s.Supplier)
            //.WithMany()
            //.HasForeignKey(s => s.Supplier_ID)
            //.OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Received_Supplier_Order_Line>()
                .HasOne(r => r.Received_Supplier_Order)
                .WithMany(r => r.Received_Supplier_Order_Lines)  // Assuming Received_Supplier_Order has a collection of Received_Supplier_Order_Lines
                .HasForeignKey(r => r.Received_Supplier_Order_ID)
                .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Received_Supplier_Order_Line>()
                .HasOne(r => r.Supplier_Order_Line)
                .WithMany()  // Assuming Supplier_Order_Line does not need a navigation property for Received_Supplier_Order_Lines
                .HasForeignKey(r => r.Supplier_Order_Line_ID)
                .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Received_Supplier_Order_Line>()
                .HasOne(r => r.Product)
                .WithMany()  // Assuming Product does not need a navigation property for Received_Supplier_Order_Lines
                .HasForeignKey(r => r.Product_ID)
                .OnDelete(DeleteBehavior.NoAction);


            //builder.Entity<Received_Supplier_Order_Line>()
            //.HasOne(r => r.Product)
            //.WithMany()
            //.HasForeignKey(r => r.Product_ID)
            //.OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Outstanding_Payment>()
            .HasOne(op => op.Member)
            .WithMany()
            .HasForeignKey(op => op.Member_ID)
            .OnDelete(DeleteBehavior.NoAction); 

            builder.Entity<Outstanding_Payment>()
            .HasOne(op => op.Payment)
            .WithMany()
            .HasForeignKey(op => op.Payment_ID)
            .OnDelete(DeleteBehavior.NoAction);


            builder.Entity<Booking>()
            .HasOne(b => b.Member)
            .WithMany()
            .HasForeignKey(b => b.Member_ID)
            .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Reward_Member>()
            .HasOne(rm => rm.Member)
            .WithMany()
            .HasForeignKey(rm => rm.Member_ID)
            .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Reward_Member>()
            .HasOne(rm => rm.Reward)
            .WithMany()
            .HasForeignKey(rm => rm.Reward_ID)
            .OnDelete(DeleteBehavior.NoAction);

           builder.Entity<Booking_Time_Slot>()
            .HasOne(bts => bts.Booking)
            .WithMany()
            .HasForeignKey(bts => bts.Booking_ID)
            .OnDelete(DeleteBehavior.NoAction);

           builder.Entity<Booking_Time_Slot>()
            .HasOne(bts => bts.Time_Slot)
            .WithMany()
            .HasForeignKey(bts => bts.Time_Slot_ID)
            .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Attendance_List>()
            .HasOne(b => b.Time_Slot)
            .WithMany()
            .HasForeignKey(b => b.Time_Slot_ID)
            .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Lesson_Plan_Workout>()
            .HasOne(lpw => lpw.Workout)
            .WithMany()
            .HasForeignKey(lpw => lpw.Workout_ID)
            .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Lesson_Plan_Workout>()
            .HasOne(lpw => lpw.Lesson_Plan)
            .WithMany()
            .HasForeignKey(lpw => lpw.Lesson_Plan_ID)
            .OnDelete(DeleteBehavior.NoAction);

            builder.Entity<Workout>()
           .HasOne(w => w.Workout_Category)
           .WithMany()
           .HasForeignKey(w => w.Workout_Category_ID)
           .IsRequired()
           .OnDelete(DeleteBehavior.Restrict);

            base.OnModelCreating(builder);



            //var Contract_Types = new Contract_Type[]
            //{
            //    new Contract_Type { Contract_Type_ID = 1, Contract_Type_Name = "3-Month Membership", Contract_Description = "Three-month gym membership contract" },              
            //};
            //builder.Entity<Contract_Type>().HasData(Contract_Types);



            var Discounts = new Discount[]
            {
                new Discount
                {
                    Discount_ID = 1,
                    Discount_Code = "SPR-123",
                    Discount_Percentage = 10.00m,
                    Discount_Date = new DateTime(2024, 4, 10),
                    End_Date = new DateTime(2024, 4, 10).AddDays(30)
                }
            };
            builder.Entity<Discount>().HasData(Discounts);


            //var Employee_Types = new Employee_Type[]
            //{
            //    new Employee_Type { Employee_Type_ID = 1, Job_Title = "Administrator", Job_Description = "Responsible for managing administrative tasks and operations" }
            //};
            //builder.Entity<Employee_Type>().HasData(Employee_Types);

            var Inspection_Statuses = new Inspection_Status[]
            {
                new Inspection_Status { Inspection_Status_ID = 1, Inspection_Status_Description= "Pending" }


            };
            builder.Entity<Inspection_Status>().HasData(Inspection_Statuses);

            var Inspection_Types = new Inspection_Type[]
            {
                new Inspection_Type { Inspection_Type_ID = 1, Inspection_Type_Name = "Safety Inspection", Inspection_Type_Criteria = "Ensure compliance with safety standards" }
    
            };
            builder.Entity<Inspection_Type>().HasData(Inspection_Types);

            var Membership_Statuses = new Membership_Status[]
            {
                new Membership_Status { Membership_Status_ID = 1, Membership_Status_Description = "Active" }

            };
            builder.Entity<Membership_Status>().HasData(Membership_Statuses);

            var Newsletters = new Newsletter[]
            {
                new Newsletter { Newsletter_ID = 1, Newsletter_Title = "Fitness Tips", Newsletter_Photo = "fitness_tips.jpg", Newsletter_Description = "Stay updated with our latest fitness tips!" }

            };
            builder.Entity<Newsletter>().HasData(Newsletters);

            //var Payment_Methods = new Payment_Method[]
            //{
            //    new Payment_Method { Payment_Method_ID = 1, Payment_Method_Name = "Payfast" }  
            //};
            //builder.Entity<Payment_Method>().HasData(Payment_Methods);

            var Payment_Types = new Payment_Type[]
            {
                new Payment_Type { Payment_Type_ID = 1, Payment_Type_Name = "Payfast" },
                new Payment_Type { Payment_Type_ID = 2, Payment_Type_Name = "EFT" },
                new Payment_Type { Payment_Type_ID = 3, Payment_Type_Name = "Debit Order" }

            };
            builder.Entity<Payment_Type>().HasData(Payment_Types);

            var ProductCategories = new Product_Category[]
            {
                new Product_Category { Product_Category_ID = 1, Category_Name = "Tops", Category_Description = "Gym Tops" },
                new Product_Category { Product_Category_ID = 2, Category_Name = "Bottoms", Category_Description = "Gym Bottoms" }
            };

            builder.Entity<Product_Category>().HasData(ProductCategories);

            var Reports = new Report[]
            {
                new Report { Report_ID = 1, Report_Name = "Monthly Sales Report", Report_Description = "Report summarizing monthly sales data", Generated_Date = new DateTime(2024, 4, 10) }
            };
            builder.Entity<Report>().HasData(Reports);

            var Reward_Types = new Reward_Type[]
            {
                new Reward_Type { Reward_Type_ID = 1, Reward_Type_Name = "Membership Renewal Discount", Reward_Criteria = "Receive a discount on membership renewal after completing a certain number of workouts" }

            };
            builder.Entity<Reward_Type>().HasData(Reward_Types);

            var Suppliers = new Supplier[]
            {
                new Supplier { Supplier_ID = 1, Name = "FitnessGear", Contact_Number = "1234567890", Email_Address = "info@fitnessgear.com", Physical_Address = "123 Fitness Street, Cityville, South Africa" }
            };
            builder.Entity<Supplier>().HasData(Suppliers);


            var userStatus = new User_Status[]
            {
                new User_Status { User_Status_ID = 1, User_Status_Description = "Actived" },
                new User_Status { User_Status_ID = 2, User_Status_Description = "Deactivated" }
            };
            builder.Entity<User_Status>().HasData(userStatus);

            var userTypes = new User_Type[]
    {
                new User_Type { User_Type_ID = 1, User_Type_Name = "Owner" },
                new User_Type { User_Type_ID = 2, User_Type_Name = "Employee" },
                new User_Type { User_Type_ID = 3, User_Type_Name = "Member" }
    };
            builder.Entity<User_Type>().HasData(userTypes);



        //    var Users = new User[]                
        //    {
        //        new User 
        //        {
        //            User_ID = 1,
        //            Id = 1,
        //            Name = "Don",
        //            Surname = "Percival",
        //            ID_Number = "0203057644931",
        //            Email = "DonPercival@gmail.com",
        //            Physical_Address = "456 Oak Avenue",
        //            PhoneNumber = "0734457681",
        //            Photo = "DonProfilePic.jpg",
        //            PasswordHash = "AEWR54Q35H5T4HRGRGQ",
        //            Date_of_Birth = new DateTime(1994,10,11),
        //            User_Type_ID =1,
        //            User_Status_ID =1
        //        },
        //        new User
        //        {
        //            User_ID = 2,
        //            Id = 2,
        //            Name = "Barbra",
        //            Surname = "Gordon",
        //            ID_Number = "1220231231312",
        //            Email = "barbragordon@gmail.com",
        //            Physical_Address = "456 Oak Avenue",
        //            PhoneNumber = "9876543210",
        //            Photo = "barbra_photo.jpg",
        //            PasswordHash = "HJDKL3948SJDF3JSHFD",
        //            Date_of_Birth = new DateTime(1985, 5, 15),
        //            User_Type_ID =2,
        //            User_Status_ID =1
        //        },

        //        new User

        //        {
        //        User_ID = 3,
        //        Id = 3,
        //        Name = "Jane",
        //        Surname = "Smith",
        //        ID_Number = "1220231231312",
        //        Email = "JaneSmith@gmail.com",
        //        Physical_Address = "456 Oak Avenue",
        //        PhoneNumber = "9876543210",
        //        Photo = "jane_smith_photo.jpg",    
        //        PasswordHash = "JKLFSF34JKLRE983JFSD",
        //        Date_of_Birth = new DateTime(1985, 5, 15),
        //        User_Type_ID =3,
        //        User_Status_ID =1
        //        }


        //    };
        //builder.Entity<User>().HasData(Users);








            //var Contracts = new Contract[]
            //{
            //   new Contract { Contract_ID = 1, Subscription_Date = new DateTime(2023, 1, 1), Expiry_Date = new DateTime(2023, 4, 1), Terms_Of_Agreement = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", Approval_Status = true, Approval_Date = new DateTime(2023, 1, 1), Initial_Fee = 100.00m, Contract_Type_ID = 1, Payment_Type_ID = 1 }
            //};
            //builder.Entity<Contract>().HasData(Contracts);


            //var ContractHistories = new Contract_History[]
            //{
            //    new Contract_History { Contract_History_ID = 1, Modification_Date = new DateTime(2023, 5, 15), Previous_Terms = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", Updated_Terms = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut enim ad minim veniam.", Reasons_For_Changes = "To include additional benefits for members.", Contract_ID = 1 },

            //};
            //builder.Entity<Contract_History>().HasData(ContractHistories);



            var VAT = new VAT[]
            {
               new VAT { VAT_ID = 1, VAT_Percentage = 15.00m, VAT_Date = new DateTime(2024, 1, 1) }
            };
            builder.Entity<VAT>().HasData(VAT);


            var Audit_Trails = new Audit_Trail[]
            {
                new Audit_Trail { Audit_Trail_ID = 1, Action = "Action description", Timestamp = DateTime.Now }

            };
            builder.Entity<Audit_Trail>().HasData(Audit_Trails);

            var shifts = new List<Shift>();

            // Default shift (placeholder)
            int defaultShiftId = 1;
            shifts.Add(new Shift
            {
                Shift_ID = defaultShiftId,
                Shift_Number = defaultShiftId,
                Start_Time = new TimeSpan(0, 0, 0),
                End_Time = new TimeSpan(0, 0, 0)
            });

            // Weekdays (Monday - Friday) shifts
            var startTime = new TimeSpan(6, 0, 0);
            var endTime = new TimeSpan(22, 0, 0);
            int shiftId = defaultShiftId + 1; // Start after the default shift ID

            while (startTime < endTime)
            {
                shifts.Add(new Shift
                {
                    Shift_ID = shiftId,
                    Shift_Number = shiftId,
                    Start_Time = startTime,
                    End_Time = startTime.Add(new TimeSpan(2, 0, 0))
                });
                startTime = startTime.Add(new TimeSpan(2, 0, 0));
                shiftId++;
            }

            // Saturday shifts
            startTime = new TimeSpan(6, 0, 0);
            endTime = new TimeSpan(20, 0, 0);

            while (startTime < endTime)
            {
                shifts.Add(new Shift
                {
                    Shift_ID = shiftId,
                    Shift_Number = shiftId,
                    Start_Time = startTime,
                    End_Time = startTime.Add(new TimeSpan(2, 0, 0))
                });
                startTime = startTime.Add(new TimeSpan(2, 0, 0));
                shiftId++;
            }

            // Sunday shifts
            startTime = new TimeSpan(6, 0, 0);
            endTime = new TimeSpan(14, 0, 0);

            while (startTime < endTime)
            {
                shifts.Add(new Shift
                {
                    Shift_ID = shiftId,
                    Shift_Number = shiftId,
                    Start_Time = startTime,
                    End_Time = startTime.Add(new TimeSpan(2, 0, 0))
                });
                startTime = startTime.Add(new TimeSpan(2, 0, 0));
                shiftId++;
            }

            builder.Entity<Shift>().HasData(shifts);


            //var Employees = new Employee[]
            //{
            //   new Employee { Employee_ID = 1, Employment_Date = new DateTime(2024, 4, 12), Employee_Type_ID = 1 , Shift_ID =1, User_ID = 2 }
            //};
            //builder.Entity<Employee>().HasData(Employees);


            //var Members = new Member[]
            //{
            //   new Member { Member_ID = 1, Contract_ID = 1,User_ID = 3 }
               
            //};
            //builder.Entity<Member>().HasData(Members);


            //var AttendanceLists = new Attendance_List[]
            //{

            //    new Attendance_List { Attendance_ID = 1, Number_Of_Bookings = 1, Members_Present = 10, Members_Absent = 5, Time_Slot_ID = 1}
            //};
            //builder.Entity<Attendance_List>().HasData(AttendanceLists);


            //var Bookings = new Booking[]
            //{
            //    new Booking { Booking_ID = 1,  Member_ID = 1}
            //};
            //builder.Entity<Booking>().HasData(Bookings);

            var employeeTypes = new Employee_Type[]
            {
                new Employee_Type
                {
                    Employee_Type_ID = 1,
                    Job_Title = "Admin",
                    Job_Description = "Manages administrative tasks and oversees operations."
                },
                new Employee_Type
                {
                    Employee_Type_ID = 2,
                    Job_Title = "Trainer",
                    Job_Description = "Provides training and fitness guidance to members."
                }
            };
            builder.Entity<Employee_Type>().HasData(employeeTypes);

            var workoutcategories = new Workout_Category[]
            {
                new Workout_Category { Workout_Category_ID = 1, Workout_Category_Name = "Cardio", Workout_Category_Description = "Cardio workouts to improve endurance and burn calories." },
                new Workout_Category { Workout_Category_ID = 2, Workout_Category_Name = "Strength", Workout_Category_Description = "Strength training workouts to build muscle and increase strength." },
                new Workout_Category { Workout_Category_ID = 3, Workout_Category_Name = "Flexibility", Workout_Category_Description = "Flexibility workouts to improve range of motion and reduce injury risk." }
            };
            builder.Entity<Workout_Category>().HasData(workoutcategories);


            var workouts = new Workout[]
            {
                    new Workout
                    {
                        Workout_ID = 1,
                        Workout_Name = "Cardio Blast",
                        Workout_Description = "High-intensity cardio workout to burn calories and improve endurance.",
                        Sets = 4,
                        Reps = 10,
                        Workout_Category_ID = 1
                    },
                    new Workout
                    {
                        Workout_ID = 2,
                        Workout_Name = "Strength Training",
                        Workout_Description = "Build muscle strength and endurance.",
                        Sets = 3,
                        Reps = 12,
                        Workout_Category_ID = 2
                    },
                    new Workout
                    {
                        Workout_ID = 3,
                        Workout_Name = "Flexibility Routine",
                        Workout_Description = "Improve your flexibility with this stretching routine.",
                        Sets = 2,
                        Reps = 15,
                        Workout_Category_ID = 3
                    }
            };
            builder.Entity<Workout>().HasData(workouts);


            var Lesson_Plans = new Lesson_Plan[]
            {
                new Lesson_Plan { Lesson_Plan_ID = 1, Program_Name = "Base", Program_Description = "Base program description", }

            };
            builder.Entity<Lesson_Plan>().HasData(Lesson_Plans);


            var orderStatuses = new Order_Status[]
            {
                new Order_Status { Order_Status_ID = 1, Order_Status_Description = "Ready for Collection" },
                new Order_Status { Order_Status_ID = 2, Order_Status_Description = "Overdue for Collection" },
                new Order_Status { Order_Status_ID = 3, Order_Status_Description = "Collected" },
                new Order_Status { Order_Status_ID = 4, Order_Status_Description = "Late Collection" }
            };
            builder.Entity<Order_Status>().HasData(orderStatuses);


            //var Orders = new Order[]
            //{
            //   new Order { Order_ID = 1, Order_Date = new DateTime(2024, 4, 12), Order_Details = "Example order details", Total_Price = 100.00m, Member_ID = 1, Order_Status_ID = 1 }
            //};
            //builder.Entity<Order>().HasData(Orders);


            //var Outstanding_Payments = new Outstanding_Payment[]
            //{
            //   new Outstanding_Payment { Outstanding_Payment_ID = 1, Due_Date = new DateTime(2024, 4, 12), Amount_Due = 50.00m, Late_Fee = 0.00m, Member_ID = 1, Payment_ID = 1 }
            //};
            //builder.Entity<Outstanding_Payment>().HasData(Outstanding_Payments);


            //var Owners = new Owner[]
            //{
            //   new Owner { Owner_ID = 1, User_ID = 1 }
            //};
            //builder.Entity<Owner>().HasData(Owners);



            //var Payments = new Payment[]
            //{
            //  new Payment { Payment_ID = 1, Amount = 50.00m, Payment_Date = new DateTime(2024, 4, 12) }
            //};
            //builder.Entity<Payment>().HasData(Payments);



            //var Products = new Product[]
            //{
            //    new Product { Product_ID = 1, Product_Name = "Gym T-Shirt", Product_Description = "Breathable cotton gym shirt", Product_Img = "gym_tshirt.jpg", Quantity = 50, Unit_Price = 19.99M, Size = "XS", Product_Category_ID = 1, Supplier_ID = 1 },
            //    new Product { Product_ID = 2, Product_Name = "Running Shorts", Product_Description = "Lightweight running shorts", Product_Img = "running_shorts.jpg", Quantity = 40, Unit_Price = 24.99M, Size = "M", Product_Category_ID = 2, Supplier_ID = 1 },
            //    new Product { Product_ID = 3, Product_Name = "Hoodie", Product_Description = "Fleece-lined gym hoodie", Product_Img = "hoodie.jpg", Quantity = 30, Unit_Price = 39.99M, Size = "L", Product_Category_ID = 2, Supplier_ID = 1 },
            //    new Product { Product_ID = 4, Product_Name = "Compression Tights", Product_Description = "High-performance compression tights", Product_Img = "compression_tights.jpg", Quantity = 60, Unit_Price = 29.99M, Size = "S", Product_Category_ID = 2, Supplier_ID = 1 },
            //    new Product { Product_ID = 5, Product_Name = "Gym Tank Top", Product_Description = "Sleeveless tank for workouts", Product_Img = "tank_top.jpg", Quantity = 70, Unit_Price = 15.99M, Size = "M", Product_Category_ID = 1, Supplier_ID = 1 },
            //    new Product { Product_ID = 6, Product_Name = "Sweatpants", Product_Description = "Comfortable gym sweatpants", Product_Img = "sweatpants.jpg", Quantity = 50, Unit_Price = 25.99M, Size = "L", Product_Category_ID = 2, Supplier_ID = 1 },
            //    new Product { Product_ID = 7, Product_Name = "Sports Bra", Product_Description = "Supportive sports bra", Product_Img = "sports_bra.jpg", Quantity = 40, Unit_Price = 19.99M, Size = "S", Product_Category_ID = 1, Supplier_ID = 1 },
            //    new Product { Product_ID = 8, Product_Name = "Gym Leggings", Product_Description = "High-waisted gym leggings", Product_Img = "gym_leggings.jpg", Quantity = 60, Unit_Price = 34.99M, Size = "M", Product_Category_ID = 2, Supplier_ID = 1 }
            //};

            //builder.Entity<Product>().HasData(Products);


            //var prices = new Price[]
            //{
            //    new Price { Price_ID = 1, Unit_Price = 50.00m, Product_ID = 1 }
            //};
            //builder.Entity<Price>().HasData(prices);


            //var OrderLines = new Order_Line[]
            //{
            //    new Order_Line { Order_Line_ID = 1, Order_ID = 1, Product_ID = 1 }

            //};
            //builder.Entity<Order_Line>().HasData(OrderLines);


            //var Received_Supplier_Orders = new Received_Supplier_Order[]
            //{
            //    new Received_Supplier_Order { Received_Supplier_Order_ID = 1, Supplies_Received_Date = new DateTime(20, 04, 10) }
            //};

            //builder.Entity<Received_Supplier_Order>().HasData(Received_Supplier_Orders);



            //var Received_Supplier_Order_Lines = new Received_Supplier_Order_Line[]
            //{
            //    new Received_Supplier_Order_Line { Received_Supplier_Order_Line_ID = 1,Received_Supplier_Order_ID = 1,Supplier_Order_ID = 1,Product_ID = 1,Received_Supplies_Quantity = 10 }
            //};

            //builder.Entity<Received_Supplier_Order_Line>().HasData(Received_Supplier_Order_Lines);

            var Rewards = new Reward[]
            {
                new Reward { Reward_ID = 1, IsPosted = false, Reward_Issue_Date = new DateTime(2024, 4, 10), Reward_Type_ID = 1 }

            };
            builder.Entity<Reward>().HasData(Rewards);

            //var Reward_Members = new Reward_Member[]
            //{
            //    new Reward_Member{ Reward_Member_ID = 1, IsRedeemed = false, Member_ID = 1, Reward_ID = 1}
            //};
            //builder.Entity<Reward_Member>().HasData(Reward_Members);

            var Roles = new Role[]
            {
                new Role{ Id = 1, Name = "Owner", NormalizedName= "OWNER", isEditable = false},
                new Role{ Id = 2, Name = "Employee", NormalizedName= "EMPLOYEE", isEditable =true},
                new Role{ Id = 3, Name = "Member", NormalizedName= "MEMBER", isEditable =true}
            };
            builder.Entity<Role>().HasData(Roles);


            int claimId = 1;
            //Owner Claims
            //for each admin claim
            var ownerClaims = new Claim[]

            {
                new Claim("Booking Manager", "Create"),
                new Claim("Booking Manager", "Read"),
                new Claim("Booking Manager", "Update"),
                new Claim("Booking Manager", "Delete"),

                new Claim("Equipment Manager", "Create"),
                new Claim("Equipment Manager", "Read"),
                new Claim("Equipment Manager", "Update"),
                new Claim("Equipment Manager", "Delete"),

                new Claim("Employee Manager", "Create"),
                new Claim("Employee Manager", "Read"),
                new Claim("Employee Manager", "Update"),
                new Claim("Employee Manager", "Delete"),

                new Claim("Inventory Manager", "Create"),
                new Claim("Inventory Manager", "Read"),
                new Claim("Inventory  Manager", "Update"),
                new Claim("Inventory Manager", "Delete"),

                new Claim("Gym Manager", "Create"),
                new Claim("Gym Manager", "Read"),
                new Claim("Gym  Manager", "Update"),
                new Claim("Gym Manager", "Delete"),
            };
            //create a refrence of it in the Role Claims table
            foreach (var claim in ownerClaims) 
            {
                builder.Entity<IdentityRoleClaim<int>>().HasData(new IdentityRoleClaim<int>
                { 
                   Id = claimId++,
                   RoleId = Roles[0].Id,
                   ClaimType = claim.Type,
                   ClaimValue = claim.Value
                });
            }

            //Employee Claims , they are admin too but just for separation        
            //for each employee claim
            var employeeClaims = new Claim[]
            {
                new Claim("Booking Manager", "Create"),
                new Claim("Booking Manager", "Read"),
                new Claim("Booking Manager", "Update"),
                new Claim("Booking Manager", "Delete"),

                new Claim("Equipment Manager", "Create"),
                new Claim("Equipment Manager", "Read"),
                new Claim("Equipment Manager", "Update"),
                new Claim("Equipment Manager", "Delete"),

                new Claim("Employee Manager", "Read"),
                new Claim("Employee Manager", "Update"),

                new Claim("Inventory Manager", "Create"),
                new Claim("Inventory Manager", "Read"),
                new Claim("Inventory Manager", "Update"),
                new Claim("Inventory Manager", "Delete"),
            };
            //create a refrence of it in the Role Claims table
            foreach (var claim in employeeClaims)
            {
                builder.Entity<IdentityRoleClaim<int>>().HasData(new IdentityRoleClaim<int>
                {
                    Id = claimId++,
                    RoleId = Roles[1].Id,
                    ClaimType = claim.Type,
                    ClaimValue = claim.Value
                });
            }

            var memberClaims = new Claim[]
            {
                new Claim("Booking Interface", "Create"),
                new Claim("Booking Interface", "Read"),
                new Claim("Booking Interface", "Update"),
                new Claim("Booking Interface", "Delete"),

                new Claim("Profile", "Create"),
                new Claim("Profile", "Read"),
                new Claim("Profile", "Update"),

            };
            //create a refrence of it in the Role Claims table
            foreach (var claim in memberClaims)
            {
                builder.Entity<IdentityRoleClaim<int>>().HasData(new IdentityRoleClaim<int>
                {
                    Id = claimId++,
                    RoleId = Roles[2].Id,
                    ClaimType = claim.Type,
                    ClaimValue = claim.Value
                });
            }

            //var Supplier_Orders = new Supplier_Order[]
            //{
            //    new Supplier_Order { Supplier_Order_ID = 1, Date = new DateTime(2024, 4, 10), Supplier_Order_Details = "Ordered 50 units of dumbbells and 20 yoga mats", Total_Price = 1500.00m, Supplier_ID = 1, Owner_ID = 1 }

            //};
            //builder.Entity<Supplier_Order>().HasData(Supplier_Orders);

            //var Supplier_Order_Lines = new Supplier_Order_Line[]
            //{
            //    new Supplier_Order_Line { Supplier_Order_Line_ID = 1, Supplier_Qauntity = 12, Supplier_ID = 1, Product_ID = 1 }

            //};
            //builder.Entity<Supplier_Order_Line>().HasData(Supplier_Order_Lines);

            //var Inventory = new Inventory[]
            //{
            //    new Inventory { Inventory_ID = 1, Inventory_Item_Category = "Clothes", Inventory_Item_Name = "Men's Dry-fit Tops", Inventory_Item_Quantity = 20, Inventory_Item_Photo = "dry_fit_tops.jpg", Received_Supplier_Order_ID = 1, Supplier_ID = 1 }

            //};
            //builder.Entity<Inventory>().HasData(Inventory);

            var Equipments = new Equipment[]
            {
                
                 new Equipment{ Equipment_ID = 1, Equipment_Name = "Treadmill", Equipment_Description = "A motorized device used for running or walking while staying in one place." }
                
            };
            builder.Entity<Equipment>().HasData(Equipments);

            var Inspections = new Inspection[]
            {
                new Inspection { Inspection_ID = 1, Inspection_Date = new DateTime(2024, 4, 12),Inspection_Notes = "Holes in AVS pants" , Equipment_ID = 1,  Inspection_Type_ID = 1, Inspection_Status_ID = 1 }

            };
            builder.Entity<Inspection>().HasData(Inspections);

            var Booking_Time_Slots = new Booking_Time_Slot[]
            {
                new Booking_Time_Slot{Booking_Time_Slot_ID = 1, Booking_ID = 1,Time_Slot_ID = 1}
            };
            builder.Entity<Booking_Time_Slot>();


            //var Time_Slots = new Time_Slot[]
            //{

            //    new Time_Slot{Time_Slot_ID = 1,Slot_Date =  new DateTime(2024, 4, 12)  , Slot_Time = DateTime.Parse("11:00:00"), Availability = true, Lesson_Plan_ID= 1, Employee_ID=1}

            //};
            //builder.Entity<Time_Slot>().HasData(Time_Slots);


            //var Write_Offs = new Write_Off[]
            //{
            //    new Write_Off { Write_Off_ID = 1, Date = new DateTime(2024, 4, 12), Write_Off_Reason = "Expired items", Inventory_ID = 1 }

            //};
            //builder.Entity<Write_Off>().HasData(Write_Offs);


            var lessonPlanWorkOuts = new Lesson_Plan_Workout[]
            {
                new Lesson_Plan_Workout {Lesson_Plan_Workout_ID =1, Lesson_Plan_ID = 1, Workout_ID = 1}
            };
            builder.Entity<Lesson_Plan_Workout>().HasData(lessonPlanWorkOuts);

        }

    }
}

content_copyCOPY