private async void DeleteBoilerplate(BoilerplateAnswer param) { MessageDialogResult result = await _dialogCoordinator.ShowMessageAsync(this, "Delete Boilerplate Answer", "Are you sure?", MessageDialogStyle.AffirmativeAndNegative); if (result.Equals(MessageDialogResult.Affirmative)) { try { var theItem = BoilerplateAnswers.FirstOrDefault(item => item.Title.Equals(param.Title)); BoilerplateAnswers.Remove(theItem); param.Boilerplate.Delete(); } catch (Exception e) { await _dialogCoordinator.ShowMessageAsync(this, "Delete Boilerplate Answer", "Unable to delete: " + e.Message); } } }
public async void UpdateBoilerplate(Data.Boilerplate bp) { BoilerplateEditorViewModel bpdc = (BoilerplateEditorViewModel)_boilerplate_dialog.DataContext; if (!bpdc.Cancel && bpdc.Exception == null) { BoilerplateAnswer bpa = BoilerplateAnswers.FirstOrDefault(item => item.Title.Equals(bp.Title)); if (bpa == null) { BoilerplateAnswers.Add(new BoilerplateAnswer(bp, () => { boilerPlateSelected(bp); })); } else { // this won't update the text in the datagrid though... bpa.Text = bp.Text; bpa.Title = bp.Title; } } if (bpdc.Exception != null) { await _dialogCoordinator.ShowMessageAsync(this, "Add Boilerplate Answer", "Unable to save: " + bpdc.Exception.Message); } }