public Employee CreateEmployee(Employee employee)
 {
     using (var database = new Core.Entity.SeedsEntities())
     {
         var entity = employee.ToEntity(database);
         entity.ID = database.Employee.Execute(MergeOption.NoTracking).Any() ? database.Employee.Execute(MergeOption.NoTracking).Max(e => e.ID) + 1 : 0;
         long subjectID = employee.Subject.ID;
         entity.SubjectID = subjectID;
         database.AddToEmployee(entity);
         database.SaveChanges();
         employee = new Employee(database.Employee.Execute(MergeOption.NoTracking).First(e => e.ID == entity.ID));
         employee.Subject = Cache.Instance.Subjects[subjectID];
         employee.Subject.Employees[employee.ID] = employee;
         return employee;
     }
 }
 private void okClick(object sender, RoutedEventArgs e)
 {
     SelectedEmployee = comboBoxEmployees.SelectedItem as Employee;
     if (SelectedEmployee != null)
     {
         if (SelectedEmployee.Password == passwordBox.Password.ComputeHash())
         {
             DialogResult = true;
         }
         else
         {
             MessageBox.Show("Введённый пароль не верен.\n\nПожалуйста, попытайтесь ввести ещё раз.");
         }
     }
     else
     {
         MessageBox.Show("Сотрудник не выбран.\n\nДля продолжения работы с программой выберите сотрудника из выпадающего списка.");
     }
 }
 public Employee EditEmployee(Employee employee)
 {
     using (var database = new Core.Entity.SeedsEntities())
     {
         var entity = database.Employee.Single(e => e.ID == employee.ID);
         employee.ApplyChanges(database, entity);
         database.SaveChanges();
         var result = new Employee(entity);
         Cache.Instance.Subjects[result.Subject.ID].Employees[result.ID] = result;
         return result;
     }
 }