public CategoriesViewModel(Client client) { _client = client; Categories = new ObservableCollection<Category>( _client.Context.Categories.ToList()); AddNewCategoryRequest = new InteractionRequest<IConfirmation>(); AddCategoryCommand = new DelegateCommand(() => AddNewCategoryRequest.Raise( new Confirmation() { Title = "Nowa kategoria", Content = new System.Windows.Controls.TextBox() { VerticalAlignment = System.Windows.VerticalAlignment.Top } }, AddCategory)); ConfirmDeleteCategoryRequest = new InteractionRequest<IConfirmation>(); DeleteCategoryCommand = new DelegateCommand(() => ConfirmDeleteCategoryRequest.Raise( new Confirmation() { Title = "Potwierdź", Content = "Czy na pewno usunąć wybraną kategorię?" }, DeleteCategory) , CanDeleteCategory); }
public QuestionsViewModel(Client client, IRegionManager regionManager) { AddCategoryCommand = new DelegateCommand(() => regionManager.RequestNavigate(Regions.MainContent, typeof(AddQuestionView).FullName)); _client = client; Questions = _client.Context .Questions .Expand("Answers") .ToArray(); foreach (var item in Questions.SelectMany(a=>a.Answers)) { client.Context.IgnoreResourceNotFoundException = true; try { client.Context.LoadProperty(item, "Score"); } catch (DataServiceClientException ex) { //Not sure why, but when NotFound then DataServiceClient throws exception //It is normal thing when navigation property = null ergo is NotFound if(!(ex.Message=="NotFound")) { throw; } } } }
public LoginView(IRegionManager regionManager, LoginContext loginContext, Client client) { _regionManager = regionManager; _loginContext = loginContext; _client = client; DataContext = this; NavigateStudent = new DelegateCommand(LoginStudent); NavigateGetTeacherPassword = new DelegateCommand(GetTeacherPassword); InitializeComponent(); }
public PasswordView(IRegionManager regionManager, LoginContext loginContext, Client client) { _regionManager = regionManager; _loginContext = loginContext; _client = client; DataContext = this; NavigateTeacher = new DelegateCommand<string>(LoginTeacher); NavigateBack = new DelegateCommand(GoBack); InitializeComponent(); }
public AddQuestionViewModel(Client client) { _client = client; SaveCommand = new DelegateCommand(DoSave); Categories = new ObservableCollection<Category>( _client.Context.Categories.ToList()); SelectedCategories = new ObservableCollection<Category>(); SelectedCategory = Categories.First(); Text = "aaa"; Answers = new ObservableCollection<Answer>(); Answers.Add(new Answer() { Text = "Abc", Score = new Score() { Points = 10 } }); Answers.Add(new Answer() { Text = "Bcd" }); Answers.Add(new Answer() { Text = "Cde" }); }