/// <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> /// Removes a certain lithounit of ID == id /// </summary> /// <param name="id"></param> public void RemoveLithostratigraphicUnit(int id) { 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>()) { tblBasinLithoUnit result = db.GetModelById(id); db.DeleteModelById(result.baslitIdPk); db.Save(); BasLithostrat = new BindableCollection <tblBasinLithoUnit>((db.GetModelByExpression(x => x.basIdFk == SelectedBasin.basIdPk).OrderBy(x => x.baslitIdPk).ToList())); } } catch (Exception e) { _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));; } finally { Refresh(); } }
/// <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 { } } }
/// <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 { } } }