private void RefreshSpecialtyProperty()
        {
            Specialties.Clear();

            try
            {
                DbContext.Specialties.OrderBy(x => x.Name).ToList().ForEach(x => Specialties.Add(x));
                OnPropertyChanged(nameof(Specialties));
            }
            catch (EntityException e)
            {
                OnEntityException(e);
            }
            catch (DbEntityValidationException e)
            {
                OnDbEntityValidationException(e);
            }
        }
Example #2
0
        public static void Init()
        {
            Specialties.Add(new Speciality
            {
                FacultyId = 123,
                Id        = 2,
                LectorId  = 321,
                Name      = "Telecommunications",
                ShortName = "TIS"
            });
            Users.Add(new User
            {
                Id         = 1,
                FacultylID = 123,
                Name       = "Boris",
                Email      = "*****@*****.**",
                TeamID     = 12
            });

            Users.Add(new User
            {
                Id         = 2,
                FacultylID = 456,
                Name       = "Stefan",
                Email      = "*****@*****.**",
                TeamID     = 12
            });

            //Initi Story
            Stories.Add(new Story
            {
                Id          = 55,
                Name        = "Controlers Story",
                Description = "Create all required controlers",
                EndDate     = new DateTime(2020, 12, 23),
                ProjectId   = 2,
                StartDate   = DateTime.Now
            });

            //Inti faculties

            Faculties.Add(new Faculty()
            {
                Id          = 1,
                Name        = "Physico-technological faculty",
                Description = "We are the best",
                ShortName   = "PTF"
            });

            //Init Teams
            Teams.Add(new Team
            {
                Id          = 43,
                Name        = "Team A",
                FacultyID   = 1,
                DateCreated = new DateTime(2019, 10, 01)
            });

            Teams.Add(new Team
            {
                Id          = 44,
                Name        = "Team B",
                FacultyID   = 1,
                DateCreated = new DateTime(2019, 10, 01)
            });

            //Init User Taks
            UserTasks.Add(new UserTask
            {
                Id = 23,
                AssignedToUserID = 2,
                Description      = "Task Description",
                EndDate          = new DateTime(2020, 11, 23),
                Name             = "Create Controlers",
                OwnerId          = 1,
                StartDate        = DateTime.Now,
                StoryId          = 55
            });

            Sprints.Add(new Sprint
            {
                Description = "Description",
                EndDate     = DateTime.Now.AddDays(5),
                Id          = 133,
                Name        = "Sprint name",
                StartDate   = DateTime.Now,
                TeamID      = 1
            });
            Lectors.Add(new Lector
            {
                Id          = 24,
                FirstName   = "Vladimir",
                LastName    = "Sovniov",
                DateStarted = new DateTime(2018, 10, 12)
            });

            Projects.Add(new Project
            {
                Description = "Project description",
                Id          = 4322,
                Name        = "Some project name",
                OwnerId     = 2
            });

            //User positions
            UserPositions.Add(new UserPosition
            {
                Id           = 1,
                PositionName = "Junior Developer",
                Description  = "Begginer C# developer"
            });
            UserPositions.Add(new UserPosition
            {
                Id           = 2,
                PositionName = "Middle Developer",
                Description  = "Experienced C# developer"
            });
            UserPositions.Add(new UserPosition
            {
                Id           = 3,
                PositionName = "Senior Developer",
                Description  = "Very experienced C# developer"
            });
        }
Example #3
0
        public void SeedDb(int a)
        {
            if (a == 0)
            {
                var dep = Departments.Add(new Department {
                    Name = "КТ", Code = 1
                });
                var sepc = Specialties.Add(new Specialty {
                    Name = "ПОИТ", Code = 1, Department = dep
                });
                var gr = Groups.Add(new Group {
                    Number = 42491, Specialty = sepc
                });

                FileInfo       newFile = new FileInfo(Directory.GetCurrentDirectory() + "\\st.xlsx");
                ExcelPackage   pck     = new ExcelPackage(newFile);
                ExcelWorksheet sheet   = pck.Workbook.Worksheets[1];

                for (int i = 1; sheet.Cells[i, 1].Value != null; i++)
                {
                    var ln = sheet.Cells[i, 1].Value.ToString().Split(' ')[0];
                    var fn = sheet.Cells[i, 1].Value.ToString().Split(' ')[1];
                    var mn = sheet.Cells[i, 1].Value.ToString().Split(' ')[2];
                    Students.Add(new Student {
                        Group = gr, FirstName = fn, MiddleName = mn, LastName = ln
                    });
                }
            }
            else
            {
                var cp1 = ControlPoints.Add(new ControlPoint {
                    Date = DateTime.ParseExact("30.09 2017", "dd.MM yyyy", null)
                });
                var cp2 = ControlPoints.Add(new ControlPoint {
                    Date = DateTime.ParseExact("30.10 2017", "dd.MM yyyy", null)
                });
                var cp3 = ControlPoints.Add(new ControlPoint {
                    Date = DateTime.ParseExact("30.11 2017", "dd.MM yyyy", null)
                });

                var sub1 = Subjects.Add(new Subject {
                    Name = "КПиЯП"
                });
                var teacher1 = Teachers.Add(new Teacher {
                    FirstName = "Марина", MiddleName = "Анатольевна", LastName = "Бельчик"
                });

                var sub2 = Subjects.Add(new Subject {
                    Name = "БДиСУБД"
                });
                var teacher2 = Teachers.Add(new Teacher {
                    FirstName = "Ольга", MiddleName = "Николаевна", LastName = "Виничук"
                });

                var sub3 = Subjects.Add(new Subject {
                    Name = "ПСИП"
                });
                foreach (var student in Students.ToList())
                {
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp1, Student = student, Subject = sub1, Teacher = teacher1
                    });
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp2, Student = student, Subject = sub1, Teacher = teacher1
                    });
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp3, Student = student, Subject = sub1, Teacher = teacher1
                    });

                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp1, Student = student, Subject = sub1, Teacher = teacher1
                    });
                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp2, Student = student, Subject = sub1, Teacher = teacher1
                    });
                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp3, Student = student, Subject = sub1, Teacher = teacher1
                    });

                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp1, Student = student, Subject = sub1, Teacher = teacher1
                    });
                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp2, Student = student, Subject = sub1, Teacher = teacher1
                    });
                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp3, Student = student, Subject = sub1, Teacher = teacher1
                    });
                }

                foreach (var student in Students.ToList())
                {
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp1, Student = student, Subject = sub2, Teacher = teacher2
                    });
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp2, Student = student, Subject = sub2, Teacher = teacher2
                    });
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp3, Student = student, Subject = sub2, Teacher = teacher2
                    });

                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp1, Student = student, Subject = sub2, Teacher = teacher2
                    });
                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp2, Student = student, Subject = sub2, Teacher = teacher2
                    });
                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp3, Student = student, Subject = sub2, Teacher = teacher2
                    });

                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp1, Student = student, Subject = sub2, Teacher = teacher2
                    });
                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp2, Student = student, Subject = sub2, Teacher = teacher2
                    });
                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp3, Student = student, Subject = sub2, Teacher = teacher2
                    });
                }

                foreach (var student in Students.ToList())
                {
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp1, Student = student, Subject = sub3, Teacher = teacher2
                    });
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp2, Student = student, Subject = sub3, Teacher = teacher2
                    });
                    student.Marks.Add(new Mark {
                        Value = new Random().Next(3, 10), ControlPoint = cp3, Student = student, Subject = sub3, Teacher = teacher2
                    });

                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp1, Student = student, Subject = sub3, Teacher = teacher2
                    });
                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp2, Student = student, Subject = sub3, Teacher = teacher2
                    });
                    student.Absences.Add(new Absence {
                        Count = 0, ControlPoint = cp3, Student = student, Subject = sub3, Teacher = teacher2
                    });

                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp1, Student = student, Subject = sub3, Teacher = teacher2
                    });
                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp2, Student = student, Subject = sub3, Teacher = teacher2
                    });
                    student.LabWorks.Add(new LabWork {
                        NotPassed = 0, ControlPoint = cp3, Student = student, Subject = sub3, Teacher = teacher2
                    });
                }
            }
            SaveChanges();
        }