public AddStudentViewModel(long id, long departmentId, bool isVisible)
        {
            Initial();

            Depersonilize dep = new Depersonilize();

            Student = dep.Undepersonilized(DbContext.Students.ToList()).FirstOrDefault(x => x.Id == id);
            if (Student != null)
            {
                IsMale = Student.Gender.Is(Gender.Male);

                foreach (var hab in Habitations)
                {
                    if (DbContext.StudentHabitations.Any(x => x.StudentId == Student.Id && x.HabitationId == hab.Id))
                    {
                        hab.IsChecked = true;
                    }
                }
                foreach (var inf in Informations)
                {
                    if (DbContext.StudentInformations.Any(x => x.StudentId == Student.Id && x.InformationId == inf.Id))
                    {
                        inf.IsChecked = true;
                    }
                }
            }


            ButtonVisibility = isVisible ? Visibility.Visible : Visibility.Hidden;
        }
Exemplo n.º 2
0
 private void SelectGroup()
 {
     if (SelectedGroup != null)
     {
         Depersonilize dep = new Depersonilize();
         Students = dep.Undepersonilized(DbContext.Students.ToList()).Where(x => x.GroupId == SelectedGroup.Id).ToList();
     }
 }
        public void EmailUndepersonilizedTest()
        {
            Depersonilize dep              = new Depersonilize();
            var           depersonilized   = dep.Depersonilized(students);
            var           undepersonilized = dep.Undepersonilized(depersonilized);

            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 17).Email, undepersonilized.FirstOrDefault(x => x.Id == 17).Email);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 5).Email, undepersonilized.FirstOrDefault(x => x.Id == 5).Email);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 9).Email, undepersonilized.FirstOrDefault(x => x.Id == 9).Email);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 21).Email, undepersonilized.FirstOrDefault(x => x.Id == 21).Email);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 27).Email, undepersonilized.FirstOrDefault(x => x.Id == 27).Email);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 15).Email, undepersonilized.FirstOrDefault(x => x.Id == 15).Email);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 22).Email, undepersonilized.FirstOrDefault(x => x.Id == 22).Email);
        }
        public void LastNameUndepersonilizedTest()
        {
            Depersonilize dep              = new Depersonilize();
            var           depersonilized   = dep.Depersonilized(students);
            var           undepersonilized = dep.Undepersonilized(depersonilized);

            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 1).LastName, undepersonilized.FirstOrDefault(x => x.Id == 1).LastName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 3).LastName, undepersonilized.FirstOrDefault(x => x.Id == 3).LastName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 21).LastName, undepersonilized.FirstOrDefault(x => x.Id == 21).LastName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 10).LastName, undepersonilized.FirstOrDefault(x => x.Id == 10).LastName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 9).LastName, undepersonilized.FirstOrDefault(x => x.Id == 9).LastName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 22).LastName, undepersonilized.FirstOrDefault(x => x.Id == 22).LastName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 20).LastName, undepersonilized.FirstOrDefault(x => x.Id == 20).LastName);
        }
        public void PhoneUndepersonilizedTest()
        {
            Depersonilize dep              = new Depersonilize();
            var           depersonilized   = dep.Depersonilized(students);
            var           undepersonilized = dep.Undepersonilized(depersonilized);

            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 8).Phone, undepersonilized.FirstOrDefault(x => x.Id == 8).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 4).Phone, undepersonilized.FirstOrDefault(x => x.Id == 4).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 18).Phone, undepersonilized.FirstOrDefault(x => x.Id == 18).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 14).Phone, undepersonilized.FirstOrDefault(x => x.Id == 14).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 22).Phone, undepersonilized.FirstOrDefault(x => x.Id == 22).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 23).Phone, undepersonilized.FirstOrDefault(x => x.Id == 23).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 26).Phone, undepersonilized.FirstOrDefault(x => x.Id == 26).Phone);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 21).Phone, undepersonilized.FirstOrDefault(x => x.Id == 21).Phone);
        }
        public void FatherNameUndepersonilizedTest()
        {
            Depersonilize dep              = new Depersonilize();
            var           depersonilized   = dep.Depersonilized(students);
            var           undepersonilized = dep.Undepersonilized(depersonilized);

            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 7).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 7).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 10).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 10).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 6).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 6).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 2).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 2).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 26).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 26).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 25).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 25).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 18).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 18).FatherName);
            Assert.AreEqual(students.FirstOrDefault(x => x.Id == 14).FatherName, undepersonilized.FirstOrDefault(x => x.Id == 14).FatherName);
        }
        private void SelectGroup()
        {
            if (SelectedGroup != null)
            {
                var currentPerson = DbContext.Persons.FirstOrDefault(x => x.User.Login == Properties.Settings.Default.UserName);
                if (currentPerson != null && SelectedGroup.СuratorId == currentPerson.Id)
                {
                    IsAddStudentEnable    = true;
                    IsImportExporvVisible = Visibility.Visible;
                }
                else
                {
                    IsAddStudentEnable    = false;
                    IsImportExporvVisible = Visibility.Hidden;
                }
                AddStudentVM    = new AddStudentViewModel();
                StudentVisible  = Visibility.Hidden;
                SelectedStudent = null;

                Depersonilize dep = new Depersonilize();
                Students = dep.Undepersonilized(DbContext.Students.ToList()).Where(x => x.GroupId == SelectedGroup.Id).ToList();
            }
        }