namespace HomeWork.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;

    internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
            
        }

        protected override void Seed(ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
            ApplicationUser user = new ApplicationUser
            {
                Id = "8545e98f-d834-4fcd-b54c-8a9fd38ae7a4",
                Email = "scrubs767@gmail.com",
                EmailConfirmed = true,
                PasswordHash = "AFgIZDChJP1NeMGDobO/gyr17xSFRhldt2h/YhQS8yOL/maY/t/fwyoj/z/N9j+Nuw==",
                SecurityStamp = "175fc0ac-7d6b-46db-a45b-970a16ad4bba",
                PhoneNumber = "False",
                TwoFactorEnabled = false,
                LockoutEnabled = true,
                AccessFailedCount = 0,
                UserName = "scrubs767@gmail.com"
            };
           context.Users.AddOrUpdate(
                u => u.Id,
                user
                );
            context.SaveChanges();
            Semester semester = new Semester
            {
                Id = 1,
                Start = new DateTime(2015, 8, 23),
                End = new DateTime(2015, 12, 5),
                User = user
            };

            context.Semesters.AddOrUpdate(
                s => s.Id,
                semester
                );
            context.SaveChanges();
            context.Instructors.AddOrUpdate(
                new Instructor { Id = 1, Name = "Dia Carabal", UserId = "8545e98f-d834-4fcd-b54c-8a9fd38ae7a4" },
                new Instructor { Id = 2, Name = "Mike Zich", UserId = "8545e98f-d834-4fcd-b54c-8a9fd38ae7a4" },
                new Instructor { Id = 3, Name = "Mike Smith", UserId = "8545e98f-d834-4fcd-b54c-8a9fd38ae7a4" },
                new Instructor { Id = 4, Name = "Chuck Frank", UserId = "8545e98f-d834-4fcd-b54c-8a9fd38ae7a4" }
                );
            context.SaveChanges();
            context.Courses.AddOrUpdate(
                new Course { Id = 1, Name = "Math 101", Color = "255,0,0", InstructorId = 1,  SemesterId = 1 },
                new Course { Id = 2, Name = "Eng 101", Color = "0,255,0", InstructorId = 2,  SemesterId = 1 },
                new Course { Id = 3, Name = "Math 201", Color = "0,0,255", InstructorId = 3,  SemesterId = 1 },
                new Course { Id = 4, Name = "Psych 101", Color = "255,255,0", InstructorId = 4,  SemesterId = 1 }

                );
            context.SaveChanges();
            context.Assignments.AddOrUpdate(
                new Assignment { Id = 1, Name = "Read ch. 1", Due = new DateTime(2015,11,1), CourseId = 1 },
                new Assignment { Id = 2, Name = "Read ch. 2", Due = new DateTime(2015, 11, 7), CourseId = 1 },
                new Assignment { Id = 3, Name = "Homework pg. 25", Due = new DateTime(2015, 11, 8), Notes = "Questions 1, 2  and 5", CourseId = 1},

                new Assignment { Id = 4, Name = "Read ch. 1 pg 1- 15", Due = new DateTime(2015, 11, 1), CourseId = 2 },
                new Assignment { Id = 5, Name = "Read ch. 1 pg 16 - 20", Due = new DateTime(2015, 11, 1), Notes = "Pick a subject from these pages for paper", CourseId = 2 },

                new Assignment { Id = 6, Name = "Read ch. 1", Due = new DateTime(2015, 11, 1), CourseId = 3 },
                new Assignment { Id = 7, Name = "Homework pg. 13", Due = new DateTime(2015, 11, 1), CourseId = 3},

                new Assignment { Id = 8, Name = "Read ch. 1", Due = new DateTime(2015, 11, 1), CourseId = 4 },
                new Assignment { Id = 9, Name = "Read ch. 2", Due = new DateTime(2015, 11, 1), CourseId = 4 },
                new Assignment { Id = 10, Name = "Study for Quiz", Due = new DateTime(2015, 11, 1), Notes = "quiz on ch's 1 & 2", CourseId = 4 }
                );
            context.SaveChanges();
        }
    }
}
