private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { await _messageDialoService.ShowInfoDialogAsync("Невозможно загрузить элемент,возможно он был удален.", "АХТУНГ"); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
// Viene riusato sia per visualizzare un'anagrafica esistente sia per crearne una nuova. // In questo secondo caso viene passato null come parametro private async void OnOpenDetailEvent(OpenDetailViewEventargs args) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; await detailViewModel.LoadAsync(args.Id); DetailViewModels.Add(detailViewModel); } // Prima di aggiornare il ViewModel corrente Verificare se il view model corrente HasChanges if (SelectedDetailViewModel != null && SelectedDetailViewModel.HasChanges) { var result = await _messageDialogservice.ShowOkCancelDialogAsync("You've made changes. Navigate away ?", "Question"); if (result == MessageDialogResult.Cancel) { return; } } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { await _messageDialogService.ShowInfoDialogAsync("Невозможно загрузить данные," + "возможно сущность данные были удалены другим пользователем."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
/// <summary> /// /// </summary> /// <param name="AFriendId"></param> private async void OnOpenDetailViewEvent(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { await _messageDialogService.ShowInfoDialogAsync($"Could not load the entity, maybe it was deleted in the meantime by other user. The navigation is refreshed for you"); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); SelectedDetailViewModel = detailViewModel; } else { SelectedDetailViewModel = _detailViewModelCreator[args.ViewModelName]; } }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch (Exception) { await _messageDialoagService.ShowInfoDialog("Could not load the entity, " + "maybe it was deleted by another user. " + "The navigation view will be refreshed."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { await _messageDialogService.ShowInfoDialogAsync("Записът не може да бъде зареден." + " Може би вече е изтрит от друг потребител. Наигационното меню ще бъде презаредено."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch (Exception e) { await _messageDialogService.ShowInfoDialogAsync(e.Message); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { //if (SelectedDetailViewModel!= null && SelectedDetailViewModel.HasChanges) //{ // var res = _messageDialogService.ShowOkCancelDialog("There are Changes. Navigate Away?", "Question"); // if (res == MessageDialogResult.Cancel) // { // return; // } //} var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; await detailViewModel.LoadAsync(args.Id); DetailViewModels.Add(detailViewModel); } //switch (args.ViewModelName) //{ // case nameof(FriendDetailViewModel): // DetailViewModel = _friendDetailViewModelCreator(); // break; // case nameof(MeetingDetailViewModel): // DetailViewModel = _meetingDetailViewModelCreator(); // break; // default: // throw new Exception($"ViewModel {args.ViewModelName} not mapped"); //} SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { _messageDialogService.ShowInfoDialog("Could not load entity, maybe it was deleted in the meantime by" + "another uuser."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } if (SelectedDetailViewModel != null && SelectedDetailViewModel.HasChanges) { var result = _messageDialogService.ShowOkCancelDialog("You've made changes. Navigate away?", "Question"); if (result == MessageDialogResult.CANCEL) { return; } } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch (Exception ex) { await _messageDialogService.ShowInfoDialogAsync("Could not load the entity. It was deleted by another user" + "in the meantime. The navigation is refreshed for you."); await NavigationViewModel.LoadAsync(); return; } await detailViewModel.LoadAsync(args.Id); DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) // when user clicked an item in the navigation this method is called { //it is not a good idea to use MessageBox directly in our viewmodel as this would block unit test on this method var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch (Exception ex) { await _messageDialogService.ShowInfoDialogAsync("Could not load the entity, maybe it was deleted in the meantime" + " by another user. The navigation is refreshed for you."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(x => x.Id == args.Id && x.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelFactory.GetDetailViewModel(args.ViewModelName); try { await detailViewModel.LoadAsync(args.Id); } catch { await _messageDialogService.ShowInfoDialogAsync("Could not load the entity, " + "maybe it was deleted in the meantime by another user." + "The navigation is refreshed of you."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OpenDetailView(OpenDetailViewEventArgs args) { Int64 startTicks = Log.EVENT_HANDLER($"(DogMainViewModel) Enter Id:({args.Id}(", Common.LOG_APPNAME); var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { switch (args.ViewModelName) { case nameof(DogDetailViewModel): detailViewModel = (IDetailViewModel)_DogDetailViewModelCreator(); break; //case nameof(MeetingDetailViewModel): // detailViewModel = _meetingDetailViewModelCreator(); // break; case nameof(BoneDetailViewModel): detailViewModel = _BoneDetailViewModelCreator(); break; // Ignore event if we don't handle default: return; } // Verify item still exists (may have been deleted) try { await detailViewModel.LoadAsync(args.Id); } catch (Exception ex) { //MessageDialogService.ShowInfoDialog($"Cannot load the entity ({ex})" + // "It may have been deleted by another user. Updating Navigation"); var message = $"Cannot load the entity ({ex})" + "It may have been deleted by another user. Updating Navigation"; DialogService.Show("NotificationDialog", new DialogParameters($"message={message}"), r => { }); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; Log.VIEWMODEL("(DogMainViewModel) Exit", Common.LOG_APPNAME, startTicks); }
private async void OpenDetailView(OpenDetailViewEventArgs args) { Int64 startTicks = Log.EVENT_HANDLER($"(CatMainViewModel) Enter Id:({args.Id}(", Common.LOG_CATEGORY); var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { switch (args.ViewModelName) { // case nameof(CatDetailViewModel): // detailViewModel = (IDetailViewModel)_CatDetailViewModelCreator(); // break; case nameof(CatDetailViewModel): detailViewModel = (IDetailViewModel)_CatDetailViewModelCreator(); break; //case nameof(MeetingDetailViewModel): // detailViewModel = _meetingDetailViewModelCreator(); // break; case nameof(ToyDetailViewModel): detailViewModel = _ToyDetailViewModelCreator(); break; // This should not happen anymore withe TYPEEvent default: return; } // Verify item still exists (may have been deleted) try { await detailViewModel.LoadAsync(args.Id); } catch (Exception ex) { var message = $"Cannot load the entity ({ex}) It may have been deleted by another user"; DialogService.Show("NotificationDialog", new DialogParameters($"message={message}"), r => { }); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; Log.VIEWMODEL("(CatMainViewModel) Exit", Common.LOG_CATEGORY, startTicks); }
private void RemoveDetailViewModel(int id, string viewModelName) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == id && vm.GetType().Name == viewModelName); if (detailViewModel != null) { DetailViewModels.Remove(detailViewModel); } }
private void AfterDetailDeleted(AfterDetailDeletedEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel != null) { DetailViewModels.Remove(detailViewModel); } }
private void RemoveDetailMethod(int id, string viewModelName) { var detailsViewModel = DetailViewModels .SingleOrDefault(e => e.Id == id && e.GetType().Name == viewModelName); if (detailsViewModel != null) { DetailViewModels.Remove(detailsViewModel); } }
private void VisuraSaved(VisuraSavedEventArgs arg) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.GetType().Name == typeof(VisureOperationsDetailViewModel).Name); if (detailViewModel != null) { var visureOperationViewModel = detailViewModel as VisureOperationsDetailViewModel; visureOperationViewModel.UpdateVisure(arg.Visura); //await visureOperationViewModel.LoadAsync(-1); } }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(m => m.Id == args.Id && m.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _gymClientDetailViewModelCreator[args.ViewModelName]; await detailViewModel.LoadAsync(args.Id); DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private void AfterDetailDeleted(AfterDetailDeletedEventArgs args) { // The corrisponding view will be hidden if (args.ViewModelName == typeof(VisuraDetailViewModel).Name) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.GetType().Name == typeof(VisureOperationsDetailViewModel).Name); if (detailViewModel != null) { var operationsViewModel = detailViewModel as VisureOperationsDetailViewModel; operationsViewModel.DeleteVisura(args.Id); } } RemoveDetailViewModel(args.Id, args.ViewModelName); }
private void RemoveDetailViewModel(int id, string viewModelName) { Int64 startTicks = Log.VIEWMODEL("Enter", Common.LOG_CATEGORY); var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == id && vm.GetType().Name == viewModelName); if (detailViewModel != null) { DetailViewModels.Remove(detailViewModel); } Log.VIEWMODEL("Exit", Common.LOG_CATEGORY, startTicks); }
/*public IFriendDetailViewModel FriendDetailViewModel { get; }*/ // We don`t need set becouse we setup property directly into ctor, we bind it to friendView // WE DON`T NEED THIS IN MainViewModel //public ObservableCollection<Friend> Friends { get; set; } //public Friend SelectedFriend //{ // get { return _selectedFriend; } // set // { // _selectedFriend = value; // OnPropertyChanged(); // rise event handler; property name if automaticly passed from compiler via atribut in the method // } //} // This method is called whenever user click item in navigation // If no one detailViewModel exist one is created by if statement private async void OnOpenDetailView(OpenDetailViewEventArgs args) { // args.Id contain Id of view that is clicked var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); // If ViewModel did not exist in observable collection if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { await _messageDialogService.ShowInfoDialogAsync("Could not load the entity maybe it was deleted in the meantime by another user. The navigation is refreshed for you."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } // Logic if user change something and navigate from current detailView //if (SelectedDetailViewModel != null && SelectedDetailViewModel.HasChanges) //{ // var result = _messageDialogService.ShowOkCancelDialog("You've made changes. Navigate away?", "Question"); // if (result == MessageDialogResult.Cancel) // { // return; // } //} //switch (args.ViewModelName) //{ // case nameof(FriendDetailViewModel): // DetailViewModel = _friendDetailViewModelCreator(); // break; // case nameof(MeetingDetailViewModel): // DetailViewModel = _meetingDetailViewModelCreator(); // break; // default: // throw new Exception($"ViewModel {args.ViewModelName} not mapped"); //} SelectedDetailViewModel = detailViewModel; }
/** * RemoveDetailViewModel : Notic this method just remove the detailViewModel from DetailViewModels collection * not the entity[Db] it self : * So we shared it with AfterDetailDeleted/AfterDetailClosed because either entity deleted * or user decide to close this detailWindow we need to do the same behaviour : just close the window */ private void RemoveDetailViewModel(int id, string viewModelName) { /** * Get the desired detailViewModel by it's id and viewModelName * Because if we used just id may be the entites from different tables has the same id * but this is impossible with thee entities at the same table * and we use separate viewModel for very single table * so we need to query with viewModelName */ var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == id && vm.GetType().Name == viewModelName); if (detailViewModel != null) { DetailViewModels.Remove(detailViewModel); } }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels .SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { switch (args.ViewModelName) { case nameof(FriendDetailViewModel): detailViewModel = _friendDetailViewModelCreator(); break; case nameof(MeetingDetailViewModel): detailViewModel = _meetingDetailViewModelCreator(); break; case nameof(ProgrammingLanguageDetailViewModel): detailViewModel = _programmingLanguageDetailViewModelCreator(); break; } // Verify item still exists (may have been deleted) try { await detailViewModel.LoadAsync(args.Id); } catch { _messageDialogService.ShowInfoDialog( "Cannot load the entity, it may have been deleted" + " by another user. Updating Navigation"); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) // making friendId nullable to support adding new friend. { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; await detailViewModel.LoadAsync(args.Id); DetailViewModels.Add(detailViewModel); } //if (SelectedDetailViewModel != null && SelectedDetailViewModel.HasChanges) //{ // MessageDialogResult result = _messageDialogService.ShowOkCancelDialog("You have made changes. Do you want to navigate away?", "Confirmation."); // if (result== MessageDialogResult.Cancel) // { // return; // } //} //switch(args.ViewModelName) //{ // case nameof(FriendDetailViewModel): // DetailViewModel = _friendDetailViewModelCreator(); // break; // case nameof(MeetingDetailViewModel): // DetailViewModel = _meetingDetailViewModelCreator(); // break; // default: // throw new Exception($"ViewModel {args.ViewModelName} not mapped"); // break; //} SelectedDetailViewModel = detailViewModel;// _detailViewModelCreator[args.ViewModelName]; //await SelectedDetailViewModel.LoadAsync(args.Id); }
private async void OnOpenDetailViewAsync(OpenDetailEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch { _messageDialogService.ShowInfoDialog("Could not load the entity, maybe it's was delelted in the meantime by another user , the navigation will refresh."); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { //If you don't use a tabbed view //if (SelectedDetailViewModel!=null && SelectedDetailViewModel.HasChanges) //{ // var result = _messageDialogService.ShowOkCancelDialog("You've made changes. Navigate away", "Question"); // if (result== MessageDialogResult.Cancel) // { // return; // } //} var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { //no tab is open detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id); } catch (Exception) { await _messageDialogService.ShowInfoDialogAsync("Could not load the entity, " + "maybe it was deleted in the meantime by another user. " + "The navigation is refreshed for you"); await NavigationViewModel.LoadAsync(); return; } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }
private async void OnSelectedFriendEventHandler(OpenDetailEventArgs args) { var detailsViewModel = DetailViewModels .SingleOrDefault(e => e.Id == args.Id && e.GetType().Name == args.ViewModelName); if (detailsViewModel == null) { detailsViewModel = this._detailViewModelCreator[args.ViewModelName]; try { if (args.Id == 0) { await detailsViewModel.LoadAddableAsync(); } else { await detailsViewModel.LoadAsync(args.Id); } DetailViewModels.Add(detailsViewModel); } catch { //Db Concurrency await this._messageDialogService.ShowInfoDialogAsync("Could not load the entry, Maybe is was deleted in the mentime by another user"); await NavigationViewModel.LoadAsync(); return; } } SelectedDetailViewModel = detailsViewModel; }
private async void OnOpenDetailView(OpenDtlViewEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { detailViewModel = _detailViewModelCreator[args.ViewModelName]; try { await detailViewModel.LoadAsync(args.Id, false); //Adicionado à lista de tabs DetailViewModels.Add(detailViewModel); SelectedDetailViewModel = detailViewModel; } catch (Exception) { throw; } } }
private async void OnOpenDetailView(OpenDetailViewEventArgs args) { var detailViewModel = DetailViewModels.SingleOrDefault(vm => vm.Id == args.Id && vm.GetType().Name == args.ViewModelName); if (detailViewModel == null) { switch (args.ViewModelName) { case nameof(ProjectDetailViewModel): detailViewModel = _projectDetailViewModelCreator(); break; case nameof(ProjectWorkspaceViewModel): break; case nameof(ProjectWorkspaceListViewModel): detailViewModel = _projectWokspaceListViewModelCreator(); break; case nameof(ProjectFilesListViewModel): detailViewModel = _projectFilesListViewModelCreator(); break; default: break; } if (detailViewModel != null) { await detailViewModel.LoadAsync(args.Id); } DetailViewModels.Add(detailViewModel); } SelectedDetailViewModel = detailViewModel; }