/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IDataPersons dataPersons) { _dataPersons = dataPersons; // Назначить команду для выполения. AddPersonCommand = new RelayCommand(AddPersonCommandExecute); // Назначить команду для выполения, а также команду для проверки на возможность выполнения. EditPersonCommand = new RelayCommand(EditPersonCommandExecute, EditPersonCommandCanExecute); DeletePersonCommand = new RelayCommand(DeletePersonCommandExecute, DeletePersonCommandCanExecute); // Зарегистрировать получение сообщений. Messenger.Default.Register<EditedPersonMessage>(this, EditedPersonMessageReceive); Messenger.Default.Register<PersonToAddMessage>(this, PersonToAddMessageReceive); try { RefreshPersons(); } catch (Exception exception) { // Если произошла ошибка считывания данных из бд, то создать пустую коллекцию, ибо потом БД пересоздасться. if (exception is ReadDBException) Persons = new ObservableCollection<Person>(); // Вызов исключения в UI потоке вручную, потому что инициализация MainViewModel // происходит через ServiceLocator. Application.Current.Dispatcher.BeginInvoke( new Action(() =>{ throw exception; })); } }
public OrganizationGraphType(IDataPersons data) { Name = "Organization"; Description = "Entity that represents an organization"; Field(x => x.Name).Description("Name of organization"); Field <ListGraphType <PeopleGraphType> >("People", resolve: context => { return(data.GetPeople().Where(p => p.Organizations.Contains(context.Source.Id))); }); }
public PeopleGraphType(IDataPersons data) { Name = "Peoples"; Description = "Entity that represents the people of an organization"; Field(x => x.Name).Description("Name of person"); Field <ListGraphType <OrganizationGraphType> >("Organizations", resolve: context => { return(data.GetOrganizations().Where(org => org.People.Contains(context.Source.Id))); }); }
public SearchQuery(IDataPersons data) { Name = "Query"; Field <StringGraphType>("Ping", resolve: context => "Ping ok"); Field <ListGraphType <PeopleGraphType> >("People", resolve: context => { return(data.GetPeople()); }); Field <ListGraphType <OrganizationGraphType> >("Organizations", resolve: context => { return(data.GetOrganizations()); }); }