private void InnerExecuteReplace() { try { ReplacementBsonDocument = Replacement.Deserialize <BsonDocument>(Constants.ReplacementProperty); Messenger.Default.Send(new NotificationMessage <ReplaceOneViewModel>(this, ((ResultsViewModel)Document.Parent).Owner, this, Constants.UpdateDocumentMessage)); } catch (BsonExtensions.BsonParseException ex) { LoggerHelper.Logger.Error("Exception while updating a document", ex); ErrorMessage = ex.Message; Messenger.Default.Send(new NotificationMessage <BsonExtensions.BsonParseException>(this, ex, Constants.ReplaceOneParseException)); } catch (Exception ex) { ErrorMessage = ex.Message; LoggerHelper.Logger.Error("Exception while updating a document", ex); } }
public async void InnerExecuteReplace() { Owner.Executing = true; try { var result = await Owner.Service.ReplaceOneAsync(Owner.Database, Owner.Collection, ReplaceFilter.Deserialize <BsonDocument>(Constants.ReplaceFilterProperty), Replacement.Deserialize <BsonDocument>(Constants.ReplacementProperty), Owner.Cts.Token); Owner.RawResult = result.ToJson(Options.JsonWriterSettings); Owner.RawResult += Environment.NewLine; Owner.RawResult += Environment.NewLine; Owner.RawResult += "Modified Count: " + result.ModifiedCount; Owner.SelectedViewIndex = 1; Owner.Root = null; } catch (BsonExtensions.BsonParseException ex) { LoggerHelper.Logger.Error("Exception while executing Replace command", ex); Owner.SelectedViewIndex = 1; Owner.RawResult = ex.Message; Owner.Root = null; Messenger.Default.Send(new NotificationMessage <BsonExtensions.BsonParseException>(this, ex, Constants.ReplaceParseException)); } catch (Exception ex) { LoggerHelper.Logger.Error("Exception while executing Replace command", ex); Owner.RawResult = ex.Message; Owner.SelectedViewIndex = 1; Owner.Root = null; } finally { Owner.Executing = false; Owner.ShowPager = false; } }