public async Task <ActionResult> Post([FromBody] Student student)
        {
            if (ModelState.IsValid)
            {
                if (!PasswordSecurity.CheckPasswordPolicy(student.Password))
                {
                    ModelState.AddModelError("Errors", "PASSWORD INVALID");
                    return(BadRequest(ModelState));
                }
                if (_context.EmailIsTaken(student.Email))
                {
                    ModelState.AddModelError("Errors", "Email has already been taken");
                    return(BadRequest(ModelState));
                }
                student.Password = PasswordSecurity
                                   .HashPassword(student.Password);
                student.EmailConfirmed = false;
                await _context.AddAsync(student);

                await _context.SaveChangesAsync();

                return(CreatedAtAction(nameof(Get), new { id = student.StudentId }, student));
            }
            return(BadRequest());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ForgotPassword([FromBody] ForgotPasswordModel forgotPassword)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var applicationuser = await
                                          _context
                                          .ApplicationUsers
                                          .Where(_ => _.Email == forgotPassword.Email)
                                          .FirstOrDefaultAsync();

                    var studentClaim = await
                                       _context
                                       .Students
                                       .Where(_ => _.Email == forgotPassword.Email)
                                       .FirstOrDefaultAsync();

                    var instructorClaim = await
                                          _context
                                          .Instructors
                                          .Where(_ => _.Email == forgotPassword.Email)
                                          .FirstOrDefaultAsync();

                    if (applicationuser == null)
                    {
                        // Don't reveal that the user does not exist
                        return(Ok());
                    }
                    if (!studentClaim.EmailConfirmed)
                    {
                        return(Ok());
                    }
                    if (!studentClaim.EmailConfirmed)
                    {
                        return(Ok());
                    }

                    var code = PasswordSecurity.HashPassword(forgotPassword.ResetPassword);
                    applicationuser.Code          = code;
                    applicationuser.ResetPassword = PasswordSecurity
                                                    .HashPassword(forgotPassword.ResetPassword);
                    _context.ApplicationUsers.Update(applicationuser);
                    await _context.SaveChangesAsync();

                    var callbackUrl  = Url.Action(nameof(ResetPassword), "Email", new { userId = applicationuser.UserId, code = code }, protocol: HttpContext.Request.Scheme);
                    var callbackUrl2 = Url.Action(nameof(CancelReset), "Email", new { userId = applicationuser.UserId, code = code }, protocol: HttpContext.Request.Scheme);

                    _emailManager.Send(forgotPassword.Email, "Reset Password", $"Please reset your password by clicking <a href='{callbackUrl}'>here</a><br>Not you? Click <a href='{callbackUrl2}'>here</a>");
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("Errors", "There was a problem with the email client");
                    throw(e);
                }
            }
            return(Ok());
        }
Ejemplo n.º 3
0
        public ActionResult Register(LoginDetailsVM registrationDetails)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Either username or password is empty.");
                return(View(registrationDetails));
            }

            if (dbContext.Logins.Any(m => m.Username == registrationDetails.UserName))
            {
                ModelState.AddModelError("", "User already exists.");
                return(View());
            }
            else
            {
                try
                {
                    string salt           = PasswordSecurity.GenerateSalt();
                    string hashedPassword = PasswordSecurity.HashPassword(registrationDetails.Password, salt);

                    UserDetails newUser = new UserDetails
                    {
                        DateOfBirth = DateTime.Now
                    };

                    Login newLogin = new Login
                    {
                        Username    = registrationDetails.UserName,
                        Password    = hashedPassword,
                        Salt        = salt,
                        UserDetails = newUser
                    };

                    newLogin.UserDetails.Setting = new Setting();

                    dbContext.Logins.Add(newLogin);
                    dbContext.SaveChanges();

                    return(RedirectToAction("Login", "Account"));
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Something went wrong try again.");
                    return(View(registrationDetails));
                }
            }
        }
Ejemplo n.º 4
0
        public ActionResult Login(User u)
        {
            try
            {
                u.Password = PasswordSecurity.HashPassword(u.Password);
                var user = db.Users.Where(x => x.EmailAddress == u.EmailAddress && x.Password == u.Password).FirstOrDefault();
                if (user != null)
                {
                    Session["UserID"]    = user.UserID.ToString();
                    Session["RolaFK"]    = user.RolaID.ToString();
                    Session["FirstName"] = user.FirstName.ToString();
                    Session["LastName"]  = user.LastName.ToString();
                    Session["College"]   = user.College.ToString();

                    var userRola = int.Parse(Session["RolaFK"].ToString());
                    if (Session["UserID"] != null && userRola == 1)
                    {
                        return(RedirectToAction("AdminDashBoard"));
                    }
                    else if (Session["UserID"] != null && userRola == 2)
                    {
                        return(RedirectToAction("UserDashBoard"));
                    }
                    else
                    {
                        return(RedirectToAction("Login"));
                    }
                }
                else
                {
                    ViewBag.Error = "Wrong login data";
                    //var alert = Content("<script language='javascript' type='text/javascript'>alert('Wrong login data!');</script>");
                    //Content("<script language='javascript' type='text/javascript'>alert('Wrong login data!');</script>");
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = "Write your data corectly";
            }

            return(View("Login", new User()));
        }
Ejemplo n.º 5
0
        public static void SeedTestDatabaseUsers(this ApplicationDbContext context)
        {
            var seededUsers = new List <User>
            {
                new User
                {
                    UserId       = 1,
                    FirstName    = "Greg",
                    LastName     = "Michael",
                    Username     = "******",
                    Email        = "*****@*****.**",
                    BirthDate    = new DateTime(1995, 9, 15),
                    PasswordHash = PasswordSecurity.HashPassword("secret")
                },
                new User
                {
                    UserId       = 2,
                    FirstName    = "John",
                    LastName     = "Moeller",
                    Username     = "******",
                    Email        = "*****@*****.**",
                    BirthDate    = new DateTime(1990, 12, 23),
                    PasswordHash = PasswordSecurity.HashPassword("secret2")
                },
                new User
                {
                    FirstName    = "Marcus",
                    LastName     = "Fenix",
                    Username     = "******",
                    Email        = "*****@*****.**",
                    BirthDate    = new DateTime(1999, 12, 12),
                    PasswordHash = PasswordSecurity.HashPassword("secret3")
                }
            };

            context.AddRange(seededUsers);
            context.SaveChanges();
        }
Ejemplo n.º 6
0
        public ActionResult Register([Bind(Include = "UserID,FirstName,LastName,EmailAddress,Password,Remember,College")] User user)
        {
            var userr = db.Users.Where(x => x.EmailAddress == user.EmailAddress).FirstOrDefault();

            try
            {
                if (userr == null)
                {
                    if (PasswordSecurity.CheckPassword(user.Password))
                    {
                        if (ModelState.IsValid)
                        {
                            user.Password = PasswordSecurity.HashPassword(user.Password);
                            user.RolaID   = 2;
                            db.Users.Add(user);
                            db.SaveChanges();

                            return(RedirectToAction("Login", user));
                        }
                    }
                    else
                    {
                        TempData["Error"] = "<script>alert('The password must have minimum 7 letter, one special char, one number, one upper and lower case letter!');</script>";
                        //Content("<script language='javascript' type='text/javascript'>alert('Your Password had to: minimum 7 letter, one special char, one number, one upper and lower case letter!');</script>");
                    }
                }
                else
                {
                    ViewBag.Error = "Email exist in databse";
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = e;
            }
            return(View("Register", new User()));
        }
        public async Task <ActionResult> Post([FromBody] Administrator administrator)
        {
            if (ModelState.IsValid)
            {
                if (!PasswordSecurity.CheckPasswordPolicy(administrator.Password))
                {
                    ModelState.AddModelError("Errors", "PASSWORD INVALID");
                    return(BadRequest(ModelState));
                }
                if (_context.EmailIsTaken(administrator.Email))
                {
                    ModelState.AddModelError("Errors", "Email has already been taken");
                    return(BadRequest(ModelState));
                }
                administrator.Password = PasswordSecurity
                                         .HashPassword(administrator.Password);
                await _context.AddAsync(administrator);

                await _context.SaveChangesAsync();

                return(CreatedAtAction(nameof(Get), new { id = administrator.AdministratorId }, administrator));
            }
            return(BadRequest());
        }
        /*
         * Seeds the database with example data when the database tables are empty
         * and the application is in a development environment. As database tables are
         * added to the relational database schema, this code will need to be updated to
         * 1) check that the database tables are empty, and 2) seed the tables with data.
         *
         * TODO future improvements to this static method should include a method for
         * generating data when in a test environment for integration testing
         */
        public static IWebHost SeedDatabase(this IWebHost webHost)
        {
            using (var scope = webHost.Services.CreateScope())
            {
                var services    = scope.ServiceProvider;
                var environment = services.GetRequiredService <IHostEnvironment>();

                using (var context = services.GetRequiredService <ApplicationDbContext>())
                {
                    if (!context.Users.Any() && environment.IsDevelopment())
                    {
                        var seededUsers = new List <User>
                        {
                            new User
                            {
                                FirstName    = "Greg",
                                LastName     = "Michael",
                                Username     = "******",
                                Email        = "*****@*****.**",
                                BirthDate    = new DateTime(1995, 9, 15),
                                PasswordHash = PasswordSecurity.HashPassword("secret"),
                                Stats        = new Stats
                                {
                                    UserId            = 1,
                                    Weight            = 225,
                                    HeightFeet        = 6,
                                    HeightInch        = 1,
                                    Age               = 24,
                                    BodyfatPercentage = 18,
                                    WeightUnit        = BodyweightUnit.Lb
                                },
                                ResistanceTrainingSessions = new List <ResistanceTrainingSession>
                                {
                                    new ResistanceTrainingSession
                                    {
                                        TrainingSessionDate = new DateTime(year: 2020, month: 5, day: 22),
                                        Excercises          = new List <Excercise>
                                        {
                                            new Excercise
                                            {
                                                ExcerciseName = "Bench Press",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 225,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 220,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 215,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 210,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    }
                                                }
                                            },
                                            new Excercise
                                            {
                                                ExcerciseName = "Squat",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 315,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 305,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 295,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 270,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                }
                                            },
                                            new Excercise
                                            {
                                                ExcerciseName = "Row",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 155,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 145,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 135,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 135,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                }
                                            }
                                        }
                                    },
                                    new ResistanceTrainingSession
                                    {
                                        TrainingSessionDate = new DateTime(year: 2020, month: 5, day: 20),
                                        Excercises          = new List <Excercise>
                                        {
                                            new Excercise
                                            {
                                                ExcerciseName = "Bench Press",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 225,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 220,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 215,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 210,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    }
                                                }
                                            },
                                            new Excercise
                                            {
                                                ExcerciseName = "Squat",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 315,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 305,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 295,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 270,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                }
                                            },
                                            new Excercise
                                            {
                                                ExcerciseName = "Row",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 155,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 145,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 135,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 135,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            new User
                            {
                                FirstName    = "John",
                                LastName     = "Moeller",
                                Username     = "******",
                                Email        = "*****@*****.**",
                                BirthDate    = new DateTime(1990, 12, 23),
                                PasswordHash = PasswordSecurity.HashPassword("secret2"),
                                ResistanceTrainingSessions = new List <ResistanceTrainingSession>
                                {
                                    new ResistanceTrainingSession
                                    {
                                        TrainingSessionDate = new DateTime(year: 2020, month: 5, day: 22),
                                        Excercises          = new List <Excercise>
                                        {
                                            new Excercise
                                            {
                                                ExcerciseName = "Push Press",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 1,
                                                        Weight     = 225,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 1,
                                                        Weight     = 220,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 1,
                                                        Weight     = 215,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 1,
                                                        Weight     = 210,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 9
                                                    }
                                                }
                                            },
                                            new Excercise
                                            {
                                                ExcerciseName = "Deadlift",
                                                Sets          = new List <Set>
                                                {
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 315,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 305,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 295,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                    new Set
                                                    {
                                                        Reps       = 8,
                                                        Weight     = 270,
                                                        WeightUnit = WeightUnit.Pounds,
                                                        RateOfPercievedExertion = 8
                                                    },
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            new User
                            {
                                FirstName    = "Marcus",
                                LastName     = "Fenix",
                                Username     = "******",
                                Email        = "*****@*****.**",
                                BirthDate    = new DateTime(1999, 12, 12),
                                PasswordHash = PasswordSecurity.HashPassword("secret3")
                            }
                        };

                        context.AddRange(seededUsers);
                        context.SaveChanges();
                    }
                }
            }
            return(webHost);
        }
Ejemplo n.º 9
0
        public static void SeedTestDatabaseUsersWithDailyNutritionLogs(this ApplicationDbContext context)
        {
            var seededData = new List <User>
            {
                new User
                {
                    UserId             = 1,
                    FirstName          = "Greg",
                    LastName           = "Michael",
                    Username           = "******",
                    Email              = "*****@*****.**",
                    BirthDate          = new DateTime(1995, 9, 15),
                    PasswordHash       = PasswordSecurity.HashPassword("secret"),
                    DailyNutritionLogs = new List <DailyNutritionLog>
                    {
                        new DailyNutritionLog
                        {
                            NutritionLogDate = new DateTime(2020, 9, 20),
                            FoodEntries      = new List <FoodEntry>
                            {
                                new FoodEntry
                                {
                                    Calories = 300
                                },
                                new FoodEntry
                                {
                                    Calories = 500
                                },
                                new FoodEntry
                                {
                                    Calories = 1200
                                }
                            }
                        },
                        new DailyNutritionLog
                        {
                            NutritionLogDate = new DateTime(2020, 10, 15),
                            FoodEntries      = new List <FoodEntry>
                            {
                                new FoodEntry
                                {
                                    Calories = 400
                                },
                                new FoodEntry
                                {
                                    Calories = 871
                                },
                                new FoodEntry
                                {
                                    Calories = 924
                                },
                                new FoodEntry
                                {
                                    Calories = 127
                                }
                            }
                        },
                        new DailyNutritionLog
                        {
                            NutritionLogDate = new DateTime(2020, 9, 27),
                            FoodEntries      = new List <FoodEntry>
                            {
                                new FoodEntry
                                {
                                    Calories = 800
                                },
                                new FoodEntry
                                {
                                    Calories = 378
                                }
                            }
                        }
                    }
                },
                // TODO add other nutrition log data to other users
                new User
                {
                    UserId             = 2,
                    FirstName          = "John",
                    LastName           = "Moeller",
                    Username           = "******",
                    Email              = "*****@*****.**",
                    BirthDate          = new DateTime(1990, 12, 23),
                    PasswordHash       = PasswordSecurity.HashPassword("secret2"),
                    DailyNutritionLogs = new List <DailyNutritionLog>
                    {
                        new DailyNutritionLog
                        {
                            NutritionLogDate = new DateTime(2020, 9, 20),
                            FoodEntries      = new List <FoodEntry>
                            {
                                new FoodEntry
                                {
                                    Calories = 300
                                },
                                new FoodEntry
                                {
                                    Calories = 500
                                },
                                new FoodEntry
                                {
                                    Calories = 1200
                                }
                            }
                        },
                        new DailyNutritionLog
                        {
                            NutritionLogDate = new DateTime(2020, 10, 15),
                            FoodEntries      = new List <FoodEntry>
                            {
                                new FoodEntry
                                {
                                    Calories = 400
                                },
                                new FoodEntry
                                {
                                    Calories = 871
                                },
                                new FoodEntry
                                {
                                    Calories = 924
                                },
                                new FoodEntry
                                {
                                    Calories = 127
                                }
                            }
                        }
                    }
                },
                new User
                {
                    FirstName          = "Marcus",
                    LastName           = "Fenix",
                    Username           = "******",
                    Email              = "*****@*****.**",
                    BirthDate          = new DateTime(1999, 12, 12),
                    PasswordHash       = PasswordSecurity.HashPassword("secret3"),
                    DailyNutritionLogs = new List <DailyNutritionLog>()
                }
            };

            context.AddRange(seededData);
            context.SaveChanges();
        }
        public static async Task TestingSeedDatabaseThreeStudentsAsync(this ApplicationDbContext context)
        {
            var seededStudents = new List <Student>
            {
                new Student
                {
                    StudentId = 1,
                    FirstName = "Greg",
                    LastName  = "Gallagher",
                    BirthDate = new DateTime(1993, 12, 21),
                    Email     = "*****@*****.**",
                    Password  = PasswordSecurity.HashPassword("secret")
                },
                new Student
                {
                    StudentId = 2,
                    FirstName = "John",
                    LastName  = "Smith",
                    BirthDate = new DateTime(1997, 7, 23),
                    Email     = "*****@*****.**",
                    Password  = PasswordSecurity.HashPassword("secret")
                },
                new Student
                {
                    StudentId = 3,
                    FirstName = "Laura",
                    LastName  = "Jackson",
                    BirthDate = new DateTime(2001, 1, 13),
                    Email     = "*****@*****.**",
                    Password  = PasswordSecurity.HashPassword("secret")
                }
            };

            var seededInstructors = new List <Instructor>
            {
                new Instructor
                {
                    InstructorId = 1,
                    FirstName    = "Jackson",
                    LastName     = "Crawford",
                    Email        = "*****@*****.**",
                    Password     = PasswordSecurity.HashPassword("secret")
                },
                new Instructor
                {
                    InstructorId = 2,
                    FirstName    = "Maggie",
                    LastName     = "Ellis",
                    Email        = "*****@*****.**",
                    Password     = PasswordSecurity.HashPassword("secret")
                }
            };

            var seededAdmins = new List <Administrator>
            {
                new Administrator
                {
                    FirstName = "Marcus",
                    LastName  = "Weiss",
                    Email     = "*****@*****.**",
                    Password  = PasswordSecurity.HashPassword("admin")
                }
            };

            var seededCourses = new List <Course>
            {
                new Course
                {
                    CourseId      = 1,
                    CourseName    = "Database Systems",
                    CreditHours   = 3,
                    Section       = "00AA",
                    StartTime     = DateTime.Parse("9:00 AM"),
                    EndTime       = DateTime.Parse("10:45 AM"),
                    Prerequisites = new List <Prerequisite>
                    {
                        new Prerequisite
                        {
                            CourseId = 2
                        }
                    }
                },
                new Course
                {
                    CourseId    = 2,
                    CourseName  = "Data Structures",
                    CreditHours = 4,
                    Section     = "00BB",
                    StartTime   = DateTime.Parse("2:30 PM"),
                    EndTime     = DateTime.Parse("3:20 PM")
                },
                new Course
                {
                    CourseId      = 3,
                    CourseName    = "Software Engineering",
                    CreditHours   = 4,
                    Section       = "00AA",
                    StartTime     = DateTime.Parse("5:30 PM"),
                    EndTime       = DateTime.Parse("7:00 PM"),
                    Prerequisites = new List <Prerequisite>
                    {
                        new Prerequisite
                        {
                            CourseId = 1
                        }
                    }
                }
            };

            var seededRegistrations = new List <Registration>
            {
                new Registration
                {
                    RegistrationId  = 1,
                    CourseId        = 1,
                    InstructorId    = 1,
                    EnrollmentLimit = 40,
                },
                new Registration
                {
                    RegistrationId  = 2,
                    CourseId        = 2,
                    InstructorId    = 1,
                    EnrollmentLimit = 30
                },
                new Registration
                {
                    RegistrationId  = 3,
                    CourseId        = 3,
                    InstructorId    = 2,
                    EnrollmentLimit = 20
                }
            };

            var seededStudentEnrollments = new List <StudentEnrollment>
            {
                new StudentEnrollment
                {
                    StudentId      = 1,
                    RegistrationId = 1
                },
                new StudentEnrollment
                {
                    StudentId      = 1,
                    RegistrationId = 2
                },
                new StudentEnrollment
                {
                    StudentId      = 2,
                    RegistrationId = 1
                },
                new StudentEnrollment
                {
                    StudentId      = 3,
                    RegistrationId = 3
                }
            };

            await context.AddRangeAsync(seededStudents);

            await context.AddRangeAsync(seededCourses);

            await context.AddRangeAsync(seededInstructors);

            await context.AddRangeAsync(seededAdmins);

            await context.AddRangeAsync(seededRegistrations);

            await context.AddRangeAsync(seededStudentEnrollments);

            await context.SaveChangesAsync();
        }