//TODO abastrat : shitty code alert (for demo) protected override void OnCommitted() { if (string.IsNullOrEmpty(NewCategoryViewModel.Name)) { return; } try { var cat = new HospitalCategory(HospitalDataService.LazyHospitalRegistry.Value) { Name = NewCategoryViewModel.Name }; var vm = new HospitalCategoryViewModel(cat); HospitalDataService.HospitalCategoryViewModels.Add(vm); EventAggregator.GetEvent <HospitalCategoryCollectionChangedEvent>().Publish(true); HospitalDataService.HospitalCategoryViewModels.Move(HospitalCategoryViewModels.Count - 1, 0); SelectedCategory = vm; EventAggregator.GetEvent <GenericNotificationEvent>().Publish(string.Format("Category {0} has updated", vm.Name)); NewCategoryViewModel = new HospitalCategoryViewModel(new HospitalCategory(null)); } catch (Exception ex) { //TODO FIX BUGS IN THE INFASTRUCTURE //EventAggregator.GetEvent<ErrorNotificationEvent>().Publish(ex); } _reset(); }
private void _reset() { NewCategoryViewModel = new HospitalCategoryViewModel(new HospitalCategory(HospitalDataService.LazyHospitalRegistry.Value)); NewCategoryViewModel.Name = string.Empty; ClearErrors(Title); Committed = true; }
public void OnImportsSatisfied() { if (HospitalCategoryViewModels == null) { throw new Exception("Hospitals Category Data Failed to load. Please rebuild data base"); } //HospitalCategoryViewModels.CollectionChanged += delegate //{ // RaisePropertyChanged(() => HospitalCategoryViewModels); // EventAggregator.GetEvent<Events.HospitalCategoryCollectionChangedEvent>().Publish(); //}; EventAggregator.GetEvent <Events.HospitalCategoryDeletedEvent>().Subscribe(vm => this.HospitalCategoryViewModels.Remove(vm)); NewCategoryViewModel = new HospitalCategoryViewModel(new HospitalCategory(null)); }