Example #1
0
        private void SeedDb(TimeTrackerDataModelContainer ctx)
        {
            var employee = new Employee()
            {
                Id        = 1,
                FirstName = "Wieslaw",
                Surname   = "Urban",
                Role      = Roles.Engineer,
                Calendar  = new List <Calendar>()
                {
                    new Calendar()
                    {
                        EmployeeId = 1, Id = 1, Date = DateTime.Today
                    }
                }
            };

            var employee2 = new Employee()
            {
                Id        = 2,
                FirstName = "Ewelina",
                Surname   = "Urban",
                Role      = Roles.Manager,
                Calendar  = new List <Calendar>()
                {
                    new Calendar()
                    {
                        EmployeeId = 2, Id = 2, Date = DateTime.Today
                    }
                }
            };

            var project = new Project()
            {
                Id          = 1,
                Name        = "Dupa",
                Number      = "PD892",
                Description = "Projekt z dupki",
                CalendarId  = 1
            };

            var project2 = new Project()
            {
                Id          = 2,
                Name        = "Cipa",
                Number      = "PD894",
                Description = "Projekt z pipki",
                CalendarId  = 2
            };

            var project3 = new Project()
            {
                Id          = 3,
                Name        = "Cipka",
                Number      = "PD895",
                Description = "Projekt z pipki2",
                CalendarId  = 1
            };

            ctx.Employees.Add(employee);
            ctx.Employees.Add(employee2);
            ctx.Projects.Add(project);
            ctx.Projects.Add(project2);
            ctx.Projects.Add(project3);
            ctx.SaveChanges();
        }
Example #2
0
        private void SeedDb()
        {
            if (_ctx.Projects.Count() > 0)
            {
                return;
            }

            var calendar = new Calendar()
            {
                EmployeeId = 1, Id = 1, Date = DateTime.Parse("2017/05/20")
            };
            var calendar2 = new Calendar()
            {
                EmployeeId = 2, Id = 2, Date = DateTime.Today
            };

            var employee = new Employee()
            {
                Id        = 1,
                FirstName = "Wieslaw",
                Surname   = "Urban",
                Role      = Roles.Engineer,
                Email     = "*****@*****.**",
                Password  = hashPassword("sdfa")
            };

            var employee2 = new Employee()
            {
                Id        = 2,
                FirstName = "Ewelina",
                Surname   = "Urban",
                Role      = Roles.Manager,
                Email     = "*****@*****.**",
                Password  = hashPassword("cfds")
            };

            var projectName = new ProjectName()
            {
                Id          = 1,
                Name        = "PD1234 fds",
                Number      = "PD1234",
                Description = "dfsdsa"
            };

            var projectName2 = new ProjectName()
            {
                Id          = 2,
                Name        = "PD333sdfa",
                Number      = "PD333",
                Description = "Duzasdf"
            };

            var projectName3 = new ProjectName()
            {
                Id          = 3,
                Name        = "PD4 sdf",
                Number      = "PD4",
                Description = "Dudsfa"
            };

            var project = new Project()
            {
                Id            = 1,
                Hours         = 0,
                Description   = "Projekt z ddfi",
                CalendarId    = 1,
                ProjectNameId = 1
            };

            var project2 = new Project()
            {
                Id            = 2,
                Hours         = 0,
                Description   = "Projekt dsf",
                CalendarId    = 2,
                ProjectNameId = 2
            };

            var project3 = new Project()
            {
                Id            = 3,
                Hours         = 3,
                Description   = "Projektdsfds",
                CalendarId    = 2,
                ProjectNameId = 3
            };

            _ctx.Employees.Add(employee);
            _ctx.Employees.Add(employee2);
            _ctx.Calendars.Add(calendar);
            _ctx.Calendars.Add(calendar2);
            _ctx.Projects.Add(project);
            _ctx.Projects.Add(project2);
            _ctx.Projects.Add(project3);
            _ctx.ProjectNameSet.Add(projectName);
            _ctx.ProjectNameSet.Add(projectName2);
            _ctx.ProjectNameSet.Add(projectName3);
            _ctx.SaveChanges();
        }