Example #1
0
        public async Task CreateCollection()
        {
            string databaseName   = ProgramHelper.ReadDatabaseName();
            string collectionName = ProgramHelper.ReadCollectionName();

            ProgramHelper.Divider();
            DocumentCollection documentCollection = await _collectionRepository.CreateCollection(databaseName, collectionName);

            InfoAboutCollection(documentCollection);
        }
Example #2
0
        public async Task CreateDatabase()
        {
            string databaseName = ProgramHelper.ReadDatabaseName();

            await _repository.CreateDatabaseAsync(databaseName);

            bool isDatabaseExist = await _repository.CheckIfDatabaseExistAsync(databaseName);

            WriteLine("Database >>> " + databaseName + " <<< created.");
        }
Example #3
0
        public void ListDatabase()
        {
            string          databaseName = ProgramHelper.ReadDatabaseName();
            List <Database> lstDatabase  = _repository.ListDatabaseForAccount();

            ProgramHelper.Divider();
            foreach (var database in lstDatabase)
            {
                WriteLine("Id: " + database.Id);
                WriteLine("Self link: " + database.SelfLink);
                WriteLine("User link: " + database.UsersLink);
            }
            ProgramHelper.Divider();
        }
Example #4
0
        public async Task DeleteDatabase()
        {
            string databaseName = ProgramHelper.ReadDatabaseName();
            bool   result       = await _repository.DeleteDatabase(databaseName);

            if (result)
            {
                WriteLine("Database >>> " + databaseName + " <<< deleted");
            }
            else
            {
                WriteLine("Database >>> " + databaseName + " <<< not deleted");
            }
        }
Example #5
0
        public async Task DeleteCollection()
        {
            string databaseName   = ProgramHelper.ReadDatabaseName();
            string collectionName = ProgramHelper.ReadCollectionName();

            bool deleteResult = await _collectionRepository.DeleteCollection(databaseName, collectionName);

            if (deleteResult)
            {
                Success("Collection >>> " + collectionName + " <<< deleted.");
            }
            else
            {
                Error("Collection >>> " + collectionName + " <<< was not deleted.");
            }
        }
Example #6
0
        public bool InsertCollAndDatabase(ref string databaseName, ref DocumentCollection collectionName)
        {
            databaseName = ProgramHelper.ReadDatabaseName();
            string collectionId = ProgramHelper.ReadCollectionName();

            bool ifCollectionExist = _collectionRepository.CheckIfCollectionExistAsync(databaseName, collectionId);

            if (ifCollectionExist)
            {
                collectionName = _collectionRepository.GetDocumentCollection(databaseName, collectionId);
                return(true);
            }

            collectionName = new DocumentCollection()
            {
                Id = collectionId
            };
            return(false);
        }
Example #7
0
        public void ReadAllCollectionsFromDatabase()
        {
            string databaseName = ProgramHelper.ReadDatabaseName();

            _collectionRepository.ReadAllCollections(databaseName).ForEach(t => InfoAboutCollection(t));
        }