public override void Execute(object parameter) { AskUser.QuestionAsync("Create New Database", "Database name?") .ContinueWith(task => { if (task.IsCanceled) { return; } var databaseName = task.Result; if (string.IsNullOrEmpty(databaseName)) { return; } if (Path.GetInvalidPathChars().Any(databaseName.Contains)) { throw new ArgumentException("Cannot create a database with invalid path characters: " + databaseName); } ApplicationModel.Current.AddNotification(new Notification("Creating database: " + databaseName)); DatabaseCommands.EnsureDatabaseExistsAsync(databaseName) .ContinueOnSuccess(() => DatabaseCommands.ForDatabase(databaseName).EnsureSilverlightStartUpAsync()) .ContinueOnSuccessInTheUIThread(() => { ApplicationModel.Current.Server.Value.Databases.Add(new DatabaseModel(databaseName, DatabaseCommands.ForDatabase(databaseName))); ApplicationModel.Current.AddNotification(new Notification("Database " + databaseName + " created")); }) .Catch(); }); }
public override void Execute(object parameter) { AskUser.QuestionAsync("Save", "Please enter a name").ContinueOnSuccessInTheUIThread(name => { var doc = new PatchDocument { PatchOnOption = patchModel.PatchOn, Query = patchModel.QueryDoc.CurrentSnapshot.GetText(LineTerminator.Newline), Script = patchModel.Script.CurrentSnapshot.GetText(LineTerminator.Newline), SelectedItem = patchModel.SelectedItem, Id = "Studio/Patch/" + name, Values = patchModel.Values.ToList() }; var session = ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession(); session.Store(doc); session.SaveChangesAsync().ContinueOnSuccessInTheUIThread(() => patchModel.UpdateDoc(name)); }); }
public override void Execute(object _) { AskUser.QuestionAsync("Edit Document By ID", "Document ID?") .ContinueOnSuccessInTheUIThread(id => UrlUtil.Navigate("/edit?id=" + id)); }