// Sets up the form so that user can enter data. Data is later // saved when user clicks Commit. public void Add() { if (!DataValidation.CheckPrerequisites(CRUD.Add)) { return; } SelectedAnalyticalInstrument = new tblMeasuringDevice(); SelectedAnalyticalInstrument.mdUploaderId = (int)((ShellViewModel)IoC.Get <IShell>()).UserId; }
/// <summary> /// Removing a participant based on his id and the actually selected project /// </summary> /// <param name="id"></param> public void RemoveParticipant(int id) { if ((bool)((ShellViewModel)IoC.Get <IShell>()).LocalMode) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Users can't be removed in local mode."); return; } try { if (!DataValidation.CheckPrerequisites(CRUD.AddToObject, SelectedProject, (int)SelectedProject.prjCreatorIdFk, SelectedProject.prjIdPk)) { return; } } catch { return; } if (SelectedProject != null) { try { using (var db = new ApirsDatabase()) { db.Database.ExecuteSqlCommand("DELETE FROM tblPersonsProjects WHERE persIdFk=" + id.ToString() + " AND prjIdFk =" + SelectedProject.prjIdPk.ToString() + ";"); } _events.PublishOnUIThreadAsync(new SendUserMessageMessage ( 26, id, "Removed from project " + SelectedProject.prjName, "You were removed from the project " + SelectedProject.prjName, DateTime.Now )); Refresh(); } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured."); } } else { return; } }
// Commit changes from the new rock sample form // or edits made to the existing rock sample form. public void Update() { try { if (!DataValidation.CheckPrerequisites(CRUD.Update, SelectedProject, (int)SelectedProject.prjCreatorIdFk)) { return; } } catch { return; } using (var db = new ApirsRepository <tblProject>()) { try { SelectedProject.prjCreatorIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId; if (SelectedProject.prjIdPk == 0) { db.InsertModel(SelectedProject); Projects.Add(SelectedProject); ((ShellViewModel)IoC.Get <IShell>()).Projects.Add(SelectedProject); } else { db.UpdateModel(SelectedProject, SelectedProject.prjIdPk); } } catch (SqlException ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters"); } catch (Exception e) { if (e.Message.Contains("EntityValidation")) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("Please provide a project name."); } else { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpected error occurred."); } } finally { } } }
//Adding a default lithostratigraphic unit public void AddLithostratigraphicUnit() { try { if (!DataValidation.CheckPrerequisites(CRUD.AddToObject, SelectedBasin, (int)SelectedBasin.basUserIdFk, SelectedBasin.basIdPk)) { return; } } catch { return; } //Only accessible if current user uploaded the object try { if (SelectedBasin == null || SelectedBasin.basUserIdFk != (int)((ShellViewModel)IoC.Get <IShell>()).UserId) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Only the uploader can make changes to the object. Please contact him via message service."); return; } } catch { return; } try { using (var db = new ApirsRepository <tblBasinLithoUnit>()) { db.InsertModel(new tblBasinLithoUnit() { basIdFk = SelectedBasin.basIdPk, lithID = 55 }); db.Save(); BasLithostrat = new BindableCollection <tblBasinLithoUnit>((db.GetModelByExpression(x => x.basIdFk == SelectedBasin.basIdPk).OrderBy(x => x.baslitIdPk).ToList())); } } catch { _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));; } finally { Refresh(); } }
// Commit changes from the new rock sample form // or edits made to the existing rock sample form. public void Update() { if (!(bool)((ShellViewModel)IoC.Get <IShell>()).LocalMode) { if (!DataValidation.CheckPrerequisites(CRUD.Update, SelectedAnalyticalInstrument, (int)SelectedAnalyticalInstrument.mdUploaderId)) { return; } } try { using (var db = new ApirsRepository <tblMeasuringDevice>()) { if (SelectedAnalyticalInstrument.mdIdPk == 0) { db.InsertModel(SelectedAnalyticalInstrument); } else { db.UpdateModel(SelectedAnalyticalInstrument, SelectedAnalyticalInstrument.mdIdPk); } } Refresh(); } catch (SqlException ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters"); } catch (Exception e) { if (e.Message.Contains("EntityValidation")) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("Please provide a name for the instrument."); } else { _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok)); }; } finally { } }
// 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 }; }
// 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; } SelectedBasin = new tblBasin() { basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; }
/// <summary> /// Refreshing the dataset /// </summary> public override void Refresh() { try { if (!DataValidation.CheckPrerequisites(CRUD.Add)) { return; } } catch { return; } tblBasin current = SelectedBasin; int id = 0; try { if (SelectedBasin != null) { id = SelectedBasin.basIdPk; } LoadData(); SelectedBasin = Basins.Where(p => p.basIdPk == id).First(); } catch { try { LoadData(); SelectedBasin = new tblBasin() { basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpected error occurred."); } } }
/// <summary> /// Refreshing the dataset /// </summary> public override void Refresh() { try { if (!DataValidation.CheckPrerequisites(CRUD.Add)) { return; } } catch { return; } tblProject current = SelectedProject; int id = 0; try { if (SelectedProject != null) { id = SelectedProject.prjIdPk; } LoadData((int)((ShellViewModel)IoC.Get <IShell>()).UserId); SelectedProject = Projects.Where(p => p.prjIdPk == id).First(); } catch { try { LoadData((int)((ShellViewModel)IoC.Get <IShell>()).UserId); SelectedProject = new tblProject() { prjCreatorIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured."); } } }
/// <summary> /// Deleting the currently viewed rock sample /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Delete() { try { if (!DataValidation.CheckPrerequisites(CRUD.Delete, SelectedProject, (int)SelectedProject.prjCreatorIdFk)) { return; } } catch { return; } if (((ShellViewModel)IoC.Get <IShell>()).ShowQuestion("Are you sure to delete the record?") == MessageBoxViewResult.No) { return; } using (var db = new ApirsRepository <tblProject>()) { try { tblProject result = db.GetModelByExpression(p => p.prjIdPk == SelectedProject.prjIdPk).First(); if (result != null) { db.DeleteModelById(result.prjIdPk); } _events.PublishOnUIThreadAsync(new ChangeUserMessage((int)((ShellViewModel)IoC.Get <IShell>()).UserId, "")); LoadData((int)((ShellViewModel)IoC.Get <IShell>()).UserId); } catch (Exception ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured."); } finally { } } }
// 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; } SelectedProject = new tblProject() { prjCreatorIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; SelectedProject.prjCreatorIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId; }
/// <summary> /// Deleting the currently viewed rock sample /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Delete() { if (!DataValidation.CheckPrerequisites(CRUD.Delete, SelectedAnalyticalInstrument, (int)SelectedAnalyticalInstrument.mdUploaderId)) { return; } // If existing window is visible, delete the customer and all their orders. // In a real application, you should add warnings and allow the user to cancel the operation. if (((ShellViewModel)IoC.Get <IShell>()).ShowQuestion("Are you sure to delete the record?") == MessageBoxViewResult.No) { return; } using (var db = new ApirsRepository <tblMeasuringDevice>()) { try { if ((bool)((ShellViewModel)IoC.Get <IShell>()).LocalMode) { db.DeleteModelById(SelectedAnalyticalInstrument.mdIdPk); } else { db.DeleteModelById(SelectedAnalyticalInstrument.mdIdPk); db.Save(); } Refresh(); } catch (Exception ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured."); } finally { } } }
/// <summary> /// Deleting the currently viewed rock sample /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Delete() { try { if (!DataValidation.CheckPrerequisites(CRUD.Delete, SelectedBasin, (int)SelectedBasin.basUserIdFk)) { return; } } catch { return; } // If existing window is visible, delete the customer and all their orders. // In a real application, you should add warnings and allow the user to cancel the operation. if (((ShellViewModel)IoC.Get <IShell>()).ShowQuestion("Are you sure to delete the record?") == MessageBoxViewResult.No) { return; } using (var db = new ApirsRepository <tblBasin>()) { try { db.DeleteModelById(SelectedBasin.basIdPk); Basins.Remove(SelectedBasin); allBasins.Remove(SelectedBasin); } catch (Exception ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpected error occurred."); } finally { } } }
// Commit changes from the new rock sample form // or edits made to the existing rock sample form. public void Update() { try { if (!DataValidation.CheckPrerequisites(CRUD.Update, Lithostratigraphies, SelectedLithostratigraphy.UploaderId)) { return; } else if (SelectedLithostratigraphy.grName == null) { return; } } catch { return; } try { if (SelectedLithostratigraphy.Id == 0) { try { SelectedLithostratigraphy.UploaderId = (int)((ShellViewModel)IoC.Get <IShell>()).UserId; new ApirsRepository <tblUnionLithostratigraphy>().InsertModel(new tblUnionLithostratigraphy() { grName = SelectedLithostratigraphy.grName, unionLithUploaderIdFk = SelectedLithostratigraphy.UploaderId, chronostratNameFk = SelectedLithostratigraphy.Chronostratigraphy }); switch (SelectedLithostratigraphy.Hierarchy) { case "Group": new ApirsRepository <tblGroup>().InsertModel(new tblGroup() { grName = SelectedLithostratigraphy.grName, grBaseBoundary = SelectedLithostratigraphy.BaseBoundary, grTopBoundary = SelectedLithostratigraphy.TopBoundary, grCountries = SelectedLithostratigraphy.Countries, grDateDocumentation = SelectedLithostratigraphy.DateDocumentation, grLiterature = SelectedLithostratigraphy.Literature, grLithologicDescriptionShort = SelectedLithostratigraphy.LithologicDescriptionShort, grMaxThickness = SelectedLithostratigraphy.MaxThickness, grMeanThickness = SelectedLithostratigraphy.MeanThickness, grNotes = SelectedLithostratigraphy.Notes, grStates = SelectedLithostratigraphy.States, grTypeLocality = SelectedLithostratigraphy.TypeLocality }); break; case "Subgroup": new ApirsRepository <tblSubgroup>().InsertModel(new tblSubgroup() { sgName = SelectedLithostratigraphy.grName, sggrIdFk = new ApirsRepository <tblGroup>().GetModelByExpression(strat => strat.grName == SelectedLithostratigraphy.ParentName).Select(strat => strat.grIdPk).FirstOrDefault(), sgBaseBoundary = SelectedLithostratigraphy.BaseBoundary, sgTypeLocality = SelectedLithostratigraphy.TypeLocality, sgTopBoundary = SelectedLithostratigraphy.TopBoundary, sgCountries = SelectedLithostratigraphy.Countries, sgDateOfDocumentation = SelectedLithostratigraphy.DateDocumentation, sgLiterature = SelectedLithostratigraphy.Literature, sgLithologicDescriptionShort = SelectedLithostratigraphy.LithologicDescriptionShort, sgMaxThickness = SelectedLithostratigraphy.MaxThickness, sgMeanThickness = SelectedLithostratigraphy.MeanThickness, sgNotes = SelectedLithostratigraphy.Notes, sgStates = SelectedLithostratigraphy.States, sgDescription = SelectedLithostratigraphy.TypeLocality }); break; case "Formation": new ApirsRepository <tblFormation>().InsertModel(new tblFormation() { fmName = SelectedLithostratigraphy.grName, fmsgIdFk = new ApirsRepository <tblSubgroup>().GetModelByExpression(strat => strat.sgName == SelectedLithostratigraphy.ParentName).Select(strat => strat.sgIdPk).FirstOrDefault(), fmBaseBoundary = SelectedLithostratigraphy.BaseBoundary, fmTopBoundary = SelectedLithostratigraphy.TopBoundary, fmCountries = SelectedLithostratigraphy.Countries, fmLiterature = SelectedLithostratigraphy.Literature, fmDescription = SelectedLithostratigraphy.LithologicDescriptionShort, fmMaxThickness = SelectedLithostratigraphy.MaxThickness, fmMeanThickness = SelectedLithostratigraphy.MeanThickness, fmNotes = SelectedLithostratigraphy.Notes, fmStates = SelectedLithostratigraphy.States, fmDateOfDocumentation = DateTime.Now, fmTypeLocality = SelectedLithostratigraphy.TypeLocality }); break; case "Subformation": new ApirsRepository <tblSubformation>().InsertModel(new tblSubformation() { sfName = SelectedLithostratigraphy.grName, sffmId = new ApirsRepository <tblFormation>().GetModelByExpression(strat => strat.fmName == SelectedLithostratigraphy.ParentName).Select(strat => strat.fmIdPk).FirstOrDefault(), sfBaseBoundary = SelectedLithostratigraphy.BaseBoundary, sfTopBoundary = SelectedLithostratigraphy.TopBoundary, sfLiterature = SelectedLithostratigraphy.Literature, sfDescription = SelectedLithostratigraphy.LithologicDescriptionShort, sfMaxThickness = SelectedLithostratigraphy.MaxThickness, sfMeanThickness = SelectedLithostratigraphy.MeanThickness, sfNotes = SelectedLithostratigraphy.Notes, sfCountries = SelectedLithostratigraphy.Countries, sfDateOfDocumentation = DateTime.Now, sfTypeLocality = SelectedLithostratigraphy.TypeLocality }); break; } } catch (Exception e) { if (!e.InnerException.ToString().Contains("entries")) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Lithostratigraphic unit can't be added. Please check every field again."); } } } else { string tempName = ""; tblUnionLithostratigraphy result0 = new ApirsRepository <tblUnionLithostratigraphy>().GetModelByExpression(b => b.ID == SelectedLithostratigraphy.Id).First(); if (result0 != null) { tempName = result0.grName; var a = new ApirsRepository <tblUnionLithostratigraphy>().GetModelById(SelectedLithostratigraphy.Id); a.ID = SelectedLithostratigraphy.Id; a.grName = SelectedLithostratigraphy.grName; a.unionLithUploaderIdFk = SelectedLithostratigraphy.UploaderId; a.chronostratNameFk = SelectedLithostratigraphy.Chronostratigraphy; new ApirsRepository <tblUnionLithostratigraphy>().UpdateModel(a, a.ID); } switch (SelectedLithostratigraphy.Hierarchy) { case "Group": using (var db1 = new ApirsRepository <tblGroup>()) { tblGroup result = db1.GetModelByExpression(b => b.grName == tempName).First(); if (result != null) { result.grName = SelectedLithostratigraphy.grName; result.grBaseBoundary = SelectedLithostratigraphy.BaseBoundary; result.grTopBoundary = SelectedLithostratigraphy.TopBoundary; result.grCountries = SelectedLithostratigraphy.Countries; result.grDateDocumentation = SelectedLithostratigraphy.DateDocumentation; result.grLiterature = SelectedLithostratigraphy.Literature; result.grLithologicDescriptionShort = SelectedLithostratigraphy.LithologicDescriptionShort; result.grMaxThickness = SelectedLithostratigraphy.MaxThickness; result.grMeanThickness = SelectedLithostratigraphy.MeanThickness; result.grNotes = SelectedLithostratigraphy.Notes; result.grStates = SelectedLithostratigraphy.States; result.grTypeLocality = SelectedLithostratigraphy.TypeLocality; } ; db1.UpdateModel(result, result.grIdPk); } break; case "Subgroup": using (var db1 = new ApirsRepository <tblSubgroup>()) { tblSubgroup result1 = db1.GetModelByExpression(b => b.sgName == tempName).First(); if (result1 != null) { result1.sgName = SelectedLithostratigraphy.grName; result1.sgBaseBoundary = SelectedLithostratigraphy.BaseBoundary; result1.sgTopBoundary = SelectedLithostratigraphy.TopBoundary; result1.sgTypeLocality = SelectedLithostratigraphy.TypeLocality; result1.sgCountries = SelectedLithostratigraphy.Countries; result1.sgDateOfDocumentation = SelectedLithostratigraphy.DateDocumentation; result1.sgLiterature = SelectedLithostratigraphy.Literature; result1.sgLithologicDescriptionShort = SelectedLithostratigraphy.LithologicDescriptionShort; result1.sgMaxThickness = SelectedLithostratigraphy.MaxThickness; result1.sgMeanThickness = SelectedLithostratigraphy.MeanThickness; result1.sgNotes = SelectedLithostratigraphy.Notes; result1.sgStates = SelectedLithostratigraphy.States; result1.sgDescription = SelectedLithostratigraphy.TypeLocality; db1.UpdateModel(result1, result1.sgIdPk); } } break; case "Formation": using (var db1 = new ApirsRepository <tblFormation>()) { tblFormation result2 = db1.GetModelByExpression(b => b.fmName == tempName).First(); if (result2 != null) { result2.fmName = SelectedLithostratigraphy.grName; result2.fmBaseBoundary = SelectedLithostratigraphy.BaseBoundary; result2.fmTopBoundary = SelectedLithostratigraphy.TopBoundary; result2.fmCountries = SelectedLithostratigraphy.Countries; result2.fmDateOfDocumentation = SelectedLithostratigraphy.DateDocumentation; result2.fmLiterature = SelectedLithostratigraphy.Literature; result2.fmDescription = SelectedLithostratigraphy.LithologicDescriptionShort; result2.fmMaxThickness = SelectedLithostratigraphy.MaxThickness; result2.fmMeanThickness = SelectedLithostratigraphy.MeanThickness; result2.fmNotes = SelectedLithostratigraphy.Notes; result2.fmStates = SelectedLithostratigraphy.States; result2.fmTypeLocality = SelectedLithostratigraphy.TypeLocality; db1.UpdateModel(result2, result2.fmIdPk); } } break; case "Subformation": using (var db1 = new ApirsRepository <tblSubformation>()) { tblSubformation result3 = db1.GetModelByExpression(b => b.sfName == tempName).First(); if (result3 != null) { result3.sfName = SelectedLithostratigraphy.grName; result3.sfBaseBoundary = SelectedLithostratigraphy.BaseBoundary; result3.sfTopBoundary = SelectedLithostratigraphy.TopBoundary; result3.sfLiterature = SelectedLithostratigraphy.Literature; result3.sfDescription = SelectedLithostratigraphy.LithologicDescriptionShort; result3.sfMaxThickness = SelectedLithostratigraphy.MaxThickness; result3.sfMeanThickness = SelectedLithostratigraphy.MeanThickness; result3.sfNotes = SelectedLithostratigraphy.Notes; result3.sfCountries = SelectedLithostratigraphy.Countries; result3.sfDateOfDocumentation = DateTime.Now; result3.sfTypeLocality = SelectedLithostratigraphy.TypeLocality; db1.UpdateModel(result3, result3.sfIdPk); } } break; } } } catch (SqlException ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters"); } catch (Exception e) { if (e.Message.Contains("Sequence")) { return; } _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));; } }
/// <summary> /// Deleting the currently viewed rock sample /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Delete() { try { if (!DataValidation.CheckPrerequisites(CRUD.Delete, SelectedLithostratigraphy, SelectedLithostratigraphy.UploaderId)) { return; } } catch { return; } if (((ShellViewModel)IoC.Get <IShell>()).ShowQuestion("Are you sure to delete the record?", "You won't be able to retrieve the related measurement data after deleting this sample.") == MessageBoxViewResult.No) { return; } try { switch (SelectedLithostratigraphy.Hierarchy) { case "Group": tblGroup result = new ApirsRepository <tblGroup>().GetModelByExpression(b => b.grName == SelectedLithostratigraphy.grName).First(); if (result != null) { new ApirsRepository <tblGroup>().DeleteModelById(result.grIdPk); } break; case "Subgroup": tblSubgroup result1 = new ApirsRepository <tblSubgroup>().GetModelByExpression(b => b.sgName == SelectedLithostratigraphy.grName).First(); if (result1 != null) { new ApirsRepository <tblSubgroup>().DeleteModelById(result1.sgIdPk); } break; case "Formation": tblFormation result2 = new ApirsRepository <tblFormation>().GetModelByExpression(b => b.fmName == SelectedLithostratigraphy.grName).First(); if (result2 != null) { new ApirsRepository <tblFormation>().DeleteModelById(result2.fmIdPk); } break; case "Subformation": tblSubformation result3 = new ApirsRepository <tblSubformation>().GetModelByExpression(b => b.sfName == SelectedLithostratigraphy.grName).First(); if (result3 != null) { new ApirsRepository <tblSubformation>().DeleteModelById(result3.sfIdPk); } break; } tblUnionLithostratigraphy result4 = new ApirsRepository <tblUnionLithostratigraphy>().GetModelByExpression(b => b.grName == SelectedLithostratigraphy.grName).First(); if (result4 != null) { new ApirsRepository <tblUnionLithostratigraphy>().DeleteModelById(result4.ID); } Lithostratigraphies.Remove(SelectedLithostratigraphy); allLithostratigraphies.Remove(SelectedLithostratigraphy); SelectedLithostratigraphy = Lithostratigraphies.FirstOrDefault(); } catch (Exception ex) { _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));; } finally { } }
// Commit changes from the new rock sample form // or edits made to the existing rock sample form. public void Update() { try { if (!DataValidation.CheckPrerequisites(CRUD.Update, SelectedBasin, (int)SelectedBasin.basUserIdFk)) { return; } } catch (Exception e) { return; } using (var db = new ApirsRepository <tblBasin>()) { try { if (SelectedBasin.basIdPk == 0) { SelectedBasin.basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId; db.InsertModel(SelectedBasin); Basins.Add(SelectedBasin); } else { db.UpdateModel(SelectedBasin, SelectedBasin.basIdPk); db.Save(); using (var db1 = new ApirsRepository <tblBasinLithoUnit>()) { foreach (tblBasinLithoUnit litunit in BasLithostrat) { if (litunit.baslitIdPk == 0) { db1.InsertModel(litunit); } else { db1.UpdateModel(litunit, litunit.baslitIdPk); } } } } } catch (SqlException ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters"); } catch (Exception e) { if (e.Message.Contains("EntityValidation")) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("Please provide a name for the instrument."); } else { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpected error occured"); } } finally { } } }