/// <summary> /// Refreshing the dataset /// </summary> public override void Refresh() { LithostratigraphyUnion current = SelectedLithostratigraphy; try { string selected = SelectedLithostratigraphy.grName; LoadData(); LoadData(SelectedLithostratigraphy.Hierarchy.ToString()); SelectedLithostratigraphy = Lithostratigraphies.Where(x => x.grName == selected).First(); } catch { try { LoadData(); LoadData("Group"); SelectedLithostratigraphy = new LithostratigraphyUnion(); } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpected error occured."); } } }
//Initial data load method public async void LoadData(string parameter = "Group") { try { try { Lithostratigraphies = new BindableCollection <LithostratigraphyUnion>(this.allLithostratigraphies.Where(x => x.Hierarchy.Equals(parameter)).OrderBy(x => x.grName).ToList()); switch (parameter) { case "Group": ParentLithostratigraphies = new BindableCollection <LithostratigraphyUnion>(); break; case "Subgroup": ParentLithostratigraphies = new BindableCollection <LithostratigraphyUnion>(this.allLithostratigraphies.Where(x => x.Hierarchy.Equals("Group")).OrderBy(x => x.grName).ToList()); break; case "Formation": ParentLithostratigraphies = new BindableCollection <LithostratigraphyUnion>(this.allLithostratigraphies.Where(x => x.Hierarchy.Equals("Subgroup")).OrderBy(x => x.grName).ToList()); break; case "Subformation": ParentLithostratigraphies = new BindableCollection <LithostratigraphyUnion>(this.allLithostratigraphies.Where(x => x.Hierarchy.Equals("Formation")).OrderBy(x => x.grName).ToList()); break; } if (Lithostratigraphies.Count > 0) { SelectedLithostratigraphy = Lithostratigraphies.First(); } else { SelectedLithostratigraphy = new LithostratigraphyUnion() { Hierarchy = this.Hierarchy } }; } catch (Exception ex) { Lithostratigraphies = new BindableCollection <LithostratigraphyUnion>(); SelectedLithostratigraphy = new LithostratigraphyUnion() { Hierarchy = this.Hierarchy }; ParentLithostratigraphies = new BindableCollection <LithostratigraphyUnion>(); } } catch (Exception e) { Console.WriteLine(e.Message); } }
// Sets up the form so that user can enter data. Data is later // saved when user clicks Commit. public void Add() { try { if (!DataValidation.CheckPrerequisites(CRUD.Add)) { return; } } catch { return; } SelectedLithostratigraphy = new LithostratigraphyUnion() { Hierarchy = this.Hierarchy, UploaderId = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; }