PutDocumentKeyInUrl() приватный Метод

private PutDocumentKeyInUrl ( string docId, bool dontOpenNewTab ) : void
docId string
dontOpenNewTab bool
Результат void
Пример #1
0
            private void SaveDocument()
            {
                RavenJObject doc;
                RavenJObject metadata;

                try
                {
                    doc      = RavenJObject.Parse(parentModel.JsonData);
                    metadata = RavenJObject.Parse(parentModel.JsonMetadata);
                    if (parentModel.Key != null && Separator != null && metadata.Value <string>(Constants.RavenEntityName) == null)
                    {
                        var entityName = parentModel.Key.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();

                        if (entityName != null && entityName.Length > 1)
                        {
                            metadata[Constants.RavenEntityName] = char.ToUpper(entityName[0]) + entityName.Substring(1);
                        }
                        else
                        {
                            metadata[Constants.RavenEntityName] = parentModel.ExpireAt.Value;
                        }
                    }

                    if (parentModel.EnableExpiration.Value)
                    {
                        metadata["Raven-Expiration-Date"] = parentModel.ExpireAt.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffff");
                    }
                    else if (metadata.ContainsKey("Raven-Expiration-Date"))
                    {
                        metadata.Remove("Raven-Expiration-Date");
                    }
                }
                catch (Exception ex)
                {
                    ApplicationModel.Current.AddErrorNotification(ex, "Could not parse JSON");
                    return;
                }

                parentModel.UpdateMetadata(metadata);
                ApplicationModel.Current.AddInfoNotification("Saving document " + parentModel.Key + " ...");

                Etag etag = string.Equals(parentModel.DocumentKey, parentModel.Key, StringComparison.InvariantCultureIgnoreCase) || parentModel.ResolvingConflict
                                                     ? parentModel.Etag
                                                     : Etag.Empty;

                DatabaseCommands.PutAsync(parentModel.Key, etag, doc, metadata)
                .ContinueOnSuccess(result =>
                {
                    parentModel.ResolvingConflict = false;

                    ApplicationModel.Current.AddInfoNotification("Document " + result.Key + " saved");
                    parentModel.HasUnsavedChanges = false;
                    parentModel.Etag = result.ETag;
                    parentModel.PutDocumentKeyInUrl(result.Key, dontOpenNewTab: true);
                    parentModel.SetCurrentDocumentKey(result.Key);
                })
                .ContinueOnSuccess(() => new RefreshDocumentCommand(parentModel).Execute(null))
                .Catch(exception => ApplicationModel.Current.AddErrorNotification(exception, "Could not save document."));
            }