/// <summary> /// Checking the uniqueness of the name in the database /// </summary> public void CheckUniqueness() { int count; try { using (var db = new ApirsRepository <tblBasin>()) { count = db.GetModelByExpression(rs => rs.basName == SelectedBasin.basName && rs.basIdPk != SelectedBasin.basIdPk).Count(); if (count == 0) { return; } char a = 'A'; while (count > 0) { SelectedBasin.basName = SelectedBasin.basName + a.ToString(); count = db.GetModelByExpression(rs => rs.basName == SelectedBasin.basName).Count(); a++; } ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("The name was already in use. We provided a valid alternative for it:" + Environment.NewLine + SelectedBasin.basName); } } catch (Exception e) { _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));; } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblOutcrop>()) { try { Outcrops = new BindableCollection <tblOutcrop>(db.GetModelByExpression(outc => outc.outLocalName == name)); if (Outcrops.Count == 0) { SelectedOutcrop = new tblOutcrop(); SelectedOutcrop.outLocalName = name; } else if (Outcrops.Count > 1) { SelectedOutcrop = Outcrops.First(); } else { SelectedOutcrop = Outcrops.First(); } } catch { Outcrops = new BindableCollection <tblOutcrop>(); SelectedOutcrop = new tblOutcrop(); } } }
/// <summary> /// Getting the display name of a property /// </summary> /// <param name="descriptor"></param> /// <returns></returns> public static string GetPropertyColumnName(string parameter) { if (parameter != null) { try { var disp = new ApirsRepository <tblAlia>() .GetModelByExpression(x => x.alAlias == parameter) .Select(x => x.alColumnName) .First(); //// Check for DisplayName attribute and set the column header accordingly //var displayName = pd.Attributes[typeof(DisplayNameAttribute)] as DisplayNameAttribute; if (disp != null && disp != DisplayNameAttribute.Default.DisplayName) { return(disp); } } catch { return(null); } } return(null); }
/// <summary> /// Downloads images related to an ID of a certain selected object /// </summary> /// <param name="id">ID of the object</param> /// <param name="tok">Token to cancel the method</param> /// <returns></returns> public static async Task <BindableCollection <v_PictureStore> > LoadImagesAsync(int id, string type) { await Task.Delay(0); using (var db = new ApirsRepository <v_PictureStore>()) { try { switch (type) { case "Object": return(new BindableCollection <v_PictureStore>(db.GetObjectImagesAsync(id).Result)); case "RockSample": return(new BindableCollection <v_PictureStore>(db.GetRockSampleImagesAsync(id).Result)); case "Facies": return(new BindableCollection <v_PictureStore>(db.GetFaciesImagesAsync(id).Result)); case "ArchitecturalElement": return(new BindableCollection <v_PictureStore>(db.GetArchitecturalElementImagesAsync(id).Result)); default: return(new BindableCollection <v_PictureStore>()); } } catch { return(new BindableCollection <v_PictureStore>()); } } }
/// <summary> /// Loading user-related messages /// </summary> public void LoadMessages() { if (!DataValidation.CheckPrerequisites(CRUD.Load)) { return; } try { int userid = (int)((ShellViewModel)IoC.Get <IShell>()).UserId; var query = new ApirsRepository <tblMessage>().GetModelByExpression(x => x.messToPersonIdFk == userid).OrderByDescending(x => x.messDate).ToList(); foreach (tblMessage mess in query) { mess.messPlainText = StringCipher.Decrypt(mess.messPlainText, "helloPhrase").ToString(); } ((ShellViewModel)IoC.Get <IShell>()).SideMenuViewModel.Messages = new BindableCollection <tblMessage>(query); } catch (Exception e) { ((ShellViewModel)IoC.Get <IShell>()).SideMenuViewModel.Messages = new BindableCollection <tblMessage>(); } }
/// <summary> /// Downloads images related to an ID of a certain selected object /// </summary> /// <param name="id">ID of the object</param> /// <param name="tok">Token to cancel the method</param> /// <returns></returns> public static async Task <BindableCollection <v_FileStore> > LoadFilesAsync(int id, string type) { await Task.Delay(0); using (var db = new ApirsRepository <v_PictureStore>()) { try { switch (type) { case "LabMeasurement": return(new BindableCollection <v_FileStore>(db.GetLabMeasurementFileAsync(id).Result)); case "FieldMeasurement": return(new BindableCollection <v_FileStore>(db.GetFieldMeasurementFileAsync(id).Result)); case "Section": return(new BindableCollection <v_FileStore>(db.GetSectionFileAsync(id).Result)); default: return(new BindableCollection <v_FileStore>()); } } catch { return(new BindableCollection <v_FileStore>()); } } }
//Loading filtered data private void LoadData(int projectId) { try { //All persons participating in the actual project var query = new ApirsRepository <tblPerson>().GetPersonByProject(projectId); //(from p in db.tblPersons // join persprj in db.v_PersonsProject on p.persIdPk equals persprj.persIdFk // where persprj.prjIdFk == projectId // select p); //All persons registered var persons = new ApirsRepository <tblPerson>().GetModel(); //Filtering all persons out who already participate foreach (var pers in query) { persons = persons.Where(p => p.persIdPk != pers.persIdPk); } //Assign the rest of the people to the variable Persons = new BindableCollection <tblPerson>(persons.ToList()); FilteredPersons = new BindableCollection <tblPerson>(Persons); } catch (Exception e) { Persons = new BindableCollection <tblPerson>(); FilteredPersons = new BindableCollection <tblPerson>(); } }
/// <summary> /// Checking the uniqueness of the name in the database /// </summary> public void CheckUniqueness() { int count; try { using (var db = new ApirsRepository <tblUnionLithostratigraphy>()) { if (SelectedLithostratigraphy.Id == 0) { count = db.GetModelByExpression(x => x.grName == SelectedLithostratigraphy.grName).Count(); } else { count = db.GetModelByExpression(x => x.grName == SelectedLithostratigraphy.grName && x.ID != SelectedLithostratigraphy.Id).Count(); } if (count == 0) { return; } ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("The name was already in use. Please provide another name."); } } catch (Exception e) { _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));; } }
//Loading filtered data private void LoadData(int id) { using (var db = new ApirsRepository <tblIgneousFacy>()) { try { IgneousFacys = new BindableCollection <tblIgneousFacy>(db.GetModelByExpression(lft => lft.iffacIdFk == id)); if (IgneousFacys.Count == 0) { SelectedIgneousFacy = new tblIgneousFacy(); SelectedIgneousFacy.iffacIdFk = id; } else if (IgneousFacys.Count > 1) { SelectedIgneousFacy = IgneousFacys.First(); } else { SelectedIgneousFacy = IgneousFacys.First(); } } catch (Exception e) { IgneousFacys = new BindableCollection <tblIgneousFacy>(); SelectedIgneousFacy = new tblIgneousFacy(); } } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblPlug>()) { try { Plugs = new BindableCollection <tblPlug>(db.GetModelByExpression(plug => plug.plugLabel == name)); if (Plugs.Count == 0) { SelectedPlug = new tblPlug(); SelectedPlug.plugLabel = name; } else if (Plugs.Count > 1) { SelectedPlug = Plugs.First(); } else { SelectedPlug = Plugs.First(); } } catch { Plugs = new BindableCollection <tblPlug>(); SelectedPlug = new tblPlug(); } } }
/// <summary> /// Checking the uniqueness of the name in the database /// </summary> public void CheckUniqueness() { int count; try { using (var db = new ApirsRepository <tblProject>()) { count = db.GetModelByExpression(x => x.prjName == SelectedProject.prjName && x.prjIdPk != SelectedProject.prjIdPk).Count(); if (count == 0) { return; } char a = 'A'; while (count > 0) { SelectedProject.prjName = SelectedProject.prjName + a.ToString(); count = db.GetModelByExpression(x => x.prjName == SelectedProject.prjName && x.prjIdPk != SelectedProject.prjIdPk).Count(); a++; } ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("The name was already in use. We provided a valid alternative for it:" + Environment.NewLine + SelectedProject.prjName); } } catch (Exception e) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured."); } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblThinSection>()) { try { ThinSections = new BindableCollection <tblThinSection>(db.GetModelByExpression(ts => ts.tsFromSample == name)); if (ThinSections.Count == 0) { SelectedThinSection = new tblThinSection(); SelectedThinSection.tsFromSample = name; } else if (ThinSections.Count > 1) { SelectedThinSection = ThinSections.First(); } else { SelectedThinSection = ThinSections.First(); } } catch { ThinSections = new BindableCollection <tblThinSection>(); SelectedThinSection = new tblThinSection(); SelectedThinSection.tsFromSample = name; } } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblCuboid>()) { try { Cuboids = new BindableCollection <tblCuboid>(db.GetModelByExpression(cub => cub.cubLabel == name)); if (Cuboids.Count == 0) { SelectedCuboid = new tblCuboid(); SelectedCuboid.cubLabel = name; } else if (Cuboids.Count > 1) { SelectedCuboid = Cuboids.First(); } else { SelectedCuboid = Cuboids.First(); } } catch { Cuboids = new BindableCollection <tblCuboid>(); SelectedCuboid = new tblCuboid(); } } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblDrilling>()) { try { Drillings = new BindableCollection <tblDrilling>(db.GetModelByExpression(x => x.drillName == name)); if (Drillings.Count == 0) { SelectedDrilling = new tblDrilling(); SelectedDrilling.drillName = name; } else if (Drillings.Count > 1) { SelectedDrilling = Drillings.First(); } else { SelectedDrilling = Drillings.First(); } } catch { Drillings = new BindableCollection <tblDrilling>(); SelectedDrilling = new tblDrilling(); } } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblPowder>()) { try { Powders = new BindableCollection <tblPowder>(db.GetModelByExpression(pow => pow.powFromSampleName == name)); if (Powders.Count == 0) { SelectedPowder = new tblPowder(); SelectedPowder.powFromSampleName = name; } else if (Powders.Count > 1) { SelectedPowder = Powders.First(); } else { SelectedPowder = Powders.First(); } } catch { Powders = new BindableCollection <tblPowder>(); SelectedPowder = new tblPowder(); } } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblHandpiece>()) { try { Handpieces = new BindableCollection <tblHandpiece>(db.GetModelByExpression(hp => hp.hpLabelFk == name)); if (Handpieces.Count == 0) { SelectedHandpiece = new tblHandpiece(); SelectedHandpiece.hpLabelFk = name; } else if (Handpieces.Count > 1) { SelectedHandpiece = Handpieces.First(); } else { SelectedHandpiece = Handpieces.First(); } } catch { Handpieces = new BindableCollection <tblHandpiece>(); SelectedHandpiece = new tblHandpiece(); } } }
//Loading filtered data private void LoadData(string name) { using (var db = new ApirsRepository <tblTransect>()) { try { Transects = new BindableCollection <tblTransect>(db.GetModelByExpression(tra => tra.traName == name)); if (Transects.Count == 0) { SelectedTransect = new tblTransect(); SelectedTransect.traName = name; } else if (Transects.Count > 1) { SelectedTransect = Transects.First(); } else { SelectedTransect = Transects.First(); } } catch { Transects = new BindableCollection <tblTransect>(); SelectedTransect = new tblTransect() { traName = name }; } } }
//Loading filtered data private void LoadData() { try { using (var db = new ApirsRepository <tblBasin>()) { try { Basins = new BindableCollection <tblBasin>(db.GetModel().ToList()); this.allBasins = Basins; if (Basins.Count == 0) { SelectedBasin = new tblBasin() { basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } else if (Basins.Count > 1) { SelectedBasin = Basins.First(); } else { SelectedBasin = Basins.First(); } } catch { Basins = new BindableCollection <tblBasin>(); this.allBasins = Basins; SelectedBasin = new tblBasin() { basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } } using (var db = new ApirsRepository <LithostratigraphyUnion>()) { try { Lithostratigraphy = new BindableCollection <LithostratigraphyUnion>(db.GetCompleteLithostratigraphy().ToList()); } catch { Lithostratigraphy = new BindableCollection <LithostratigraphyUnion>(); } } } catch { Basins = new BindableCollection <tblBasin>(); SelectedBasin = new tblBasin() { basUserIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } }
/// <summary> /// Getting the display name of a property /// </summary> /// <param name="descriptor"></param> /// <returns></returns> public static string GetPropertyDisplayName(object descriptor) { var pd = descriptor as PropertyDescriptor; if (pd != null) { try { var disp = new ApirsRepository <tblAlia>() .GetModelByExpression(x => x.alColumnName == pd.Name && x.alImport == true && x.alAlias != "User name" && x.alAlias != "Project name" && x.alAlias != "Project ID" && x.alAlias != "Uploader ID" && x.alAlias != "Uploader" && x.alAlias != "User ID") .Select(x => x.alAlias) .First(); //// Check for DisplayName attribute and set the column header accordingly //var displayName = pd.Attributes[typeof(DisplayNameAttribute)] as DisplayNameAttribute; if (disp != null && disp != DisplayNameAttribute.Default.DisplayName) { return(disp); } } catch { return(pd.Name); } } else { var pi = descriptor as PropertyInfo; if (pi != null) { // Check for DisplayName attribute and set the column header accordingly Object[] attributes = pi.GetCustomAttributes(typeof(DisplayNameAttribute), true); for (int i = 0; i < attributes.Length; ++i) { var displayName = attributes[i] as DisplayNameAttribute; if (displayName != null && displayName != DisplayNameAttribute.Default) { return(displayName.DisplayName); } } } } return(null); }
// Commit changes from the new object form // or edits made to the existing object form. public void Update() { using (var db = new ApirsRepository <tblLithofacy>()) { try { if (SelectedLithofacy.facIdFk == 0) { try { db.InsertModel(SelectedLithofacy); } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Object can't be added. Please check every field again."); return; } } else { try { if (new ApirsRepository <tblLithofacy>().GetModelByExpression(x => x.facIdFk == SelectedLithofacy.facIdFk).Count() > 0) { db.UpdateModel(SelectedLithofacy, SelectedLithofacy.facIdFk); } else { db.InsertModel(SelectedLithofacy); } } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Object can't be added. Please check every field again."); return; } } } catch (SqlException ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters"); } catch (Exception e) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Something went wrong"); } 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, 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 { } } }
/// <summary> /// Event that is fired, when the selected project changes /// </summary> private void OnSelectedProjectChanged() { using (var db = new ApirsRepository <tblPerson>()) { try { Participants = new BindableCollection <tblPerson>(db.GetPersonByProject(SelectedProject.prjIdPk)); } catch { Participants = new BindableCollection <tblPerson>(); } } }
//Activating a background worker to select and download Files asynchronously private void OnSelectedBasinChanged() { using (var db = new ApirsRepository <tblBasinLithoUnit>()) { try { BasLithostrat = new BindableCollection <tblBasinLithoUnit>((db.GetModelByExpression(x => x.basIdFk == SelectedBasin.basIdPk).OrderBy(x => x.baslitIdPk).ToList())); } catch { BasLithostrat = new BindableCollection <tblBasinLithoUnit>(); } } }
//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 { } }
public void Update() { using (var db = new ApirsRepository <tblCuboid>()) { try { if (SelectedCuboid.cubIdPk == 0) { try { db.InsertModel(SelectedCuboid); db.Save(); TryClose(); } catch { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Cuboid can't be added. Please check every field again."); return; } } else { tblCuboid result = db.GetModelById(SelectedCuboid.cubIdPk); if (result != null) { db.UpdateModel(SelectedCuboid, SelectedCuboid.cubIdPk); db.Save(); } } } catch (SqlException ex) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Please provide valid input parameters"); } catch (Exception e) { ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("Something went wrong"); } finally { } } }
//Loading filtered data private void LoadData(int id) { using (var db = new ApirsRepository <tblProject>()) { try { Projects = new BindableCollection <tblProject>(db.GetModelByExpression(x => x.prjCreatorIdFk == id)); if (Projects.Count == 0) { SelectedProject = new tblProject() { prjCreatorIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } else if (Projects.Count > 1) { SelectedProject = Projects.First(); } else { SelectedProject = Projects.First(); } } catch (Exception e) { Projects = new BindableCollection <tblProject>(); SelectedProject = new tblProject() { prjCreatorIdFk = (int)((ShellViewModel)IoC.Get <IShell>()).UserId }; } try { ParticipatingProjects = new BindableCollection <tblProject>(db.GetProjectByParticipation((int)((ShellViewModel)IoC.Get <IShell>()).UserId)); } catch { ParticipatingProjects = new BindableCollection <tblProject>(); } } }
/// <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 { } } }
//Loading filtered data private async void LoadData() { if (!ServerInteractionHelper.IsNetworkAvailable() && !ServerInteractionHelper.TryAccessDatabase()) { AnalyticalInstruments = new BindableCollection <tblMeasuringDevice>(); SelectedAnalyticalInstrument = new tblMeasuringDevice(); return; } try { await Task.Run(() => { using (var db = new ApirsRepository <tblMeasuringDevice>()) { AnalyticalInstruments = new BindableCollection <tblMeasuringDevice>(db.GetModel().ToList()); } }); this.allAnalyticalInstruments = AnalyticalInstruments; if (AnalyticalInstruments.Count == 0) { SelectedAnalyticalInstrument = new tblMeasuringDevice(); } else if (AnalyticalInstruments.Count > 1) { SelectedAnalyticalInstrument = AnalyticalInstruments.First(); } else { SelectedAnalyticalInstrument = AnalyticalInstruments.First(); } } catch (Exception e) { AnalyticalInstruments = new BindableCollection <tblMeasuringDevice>(); this.allAnalyticalInstruments = AnalyticalInstruments; SelectedAnalyticalInstrument = new tblMeasuringDevice(); } }
/// <summary> /// Checking the uniqueness of the name in the database /// </summary> public void CheckUniqueness() { int count; if (SelectedAnalyticalInstrument.mdIdPk > 0) { return; } try { using (var db = new ApirsRepository <tblMeasuringDevice>()) { count = db.GetModelByExpression(rs => rs.mdName == SelectedAnalyticalInstrument.mdName).Count(); if (count == 0) { return; } char a = 'A'; while (count > 0) { SelectedAnalyticalInstrument.mdName = SelectedAnalyticalInstrument.mdName + a.ToString(); count = db.GetModelByExpression(rs => rs.mdName == SelectedAnalyticalInstrument.mdName).Count(); a++; } ((ShellViewModel)IoC.Get <IShell>()).ShowInformation("The name was already in use. We provided a valid alternative for it:" + Environment.NewLine + SelectedAnalyticalInstrument.mdName); NotifyOfPropertyChange(() => SelectedAnalyticalInstrument); } } catch (Exception e) { ((ShellViewModel)IoC.Get <IShell>()).ShowError("An unexpeced error occured."); } }