Пример #1
0
        public HttpJsonRequest CreateDatabase(DatabaseDocument databaseDocument, out RavenJObject doc)
        {
            if (databaseDocument.Settings.ContainsKey("Raven/DataDir") == false)
            {
                throw new InvalidOperationException("The Raven/DataDir setting is mandatory");
            }
            MultiDatabase.AssertValidName(databaseDocument.Id);
            doc = RavenJObject.FromObject(databaseDocument);

            return(createRequestForSystemDatabase("/admin/databases/" + Uri.EscapeDataString(databaseDocument.Id), HttpMethods.Put));
        }
Пример #2
0
        public HttpJsonRequest CreateDatabase(DatabaseDocument databaseDocument, out RavenJObject doc)
        {
            if (databaseDocument.Settings.ContainsKey("Raven/DataDir") == false)
            {
                throw new InvalidOperationException("The Raven/DataDir setting is mandatory");
            }
            var dbname = databaseDocument.Id.Replace("Raven/Databases/", "");

            MultiDatabase.AssertValidName(dbname);
            doc = RavenJObject.FromObject(databaseDocument);
            doc.Remove("Id");

            return(createRequestForSystemDatabase("/admin/databases/" + Uri.EscapeDataString(dbname), "PUT"));
        }
        public CreateDatabaseCommand CreateRequest(DocumentStore documentStore, DatabaseDocument databaseDocument)
        {
            _databaseName = databaseDocument.Id;
            if (databaseDocument.Settings.ContainsKey("Raven/DataDir") == false)
            {
                throw new InvalidOperationException("The Raven/DataDir setting is mandatory");
            }
            MultiDatabase.AssertValidName(databaseDocument.Id);

            var entityToBlittable           = new EntityToBlittable(null);
            var databaseDocumentAsBlittable = entityToBlittable.ConvertEntityToBlittable(databaseDocument,
                                                                                         documentStore.Conventions, _context);

            return(new CreateDatabaseCommand()
            {
                DatabaseDocument = databaseDocumentAsBlittable,
                Context = _context
            });
        }