예제 #1
0
        static void Option()
        {
            Console.WriteLine("11. Create database");
            Console.WriteLine("12. Delete database");
            Console.WriteLine("13. List database");

            ProgramHelper.Divider();
            Console.WriteLine("21. Create collection");
            Console.WriteLine("22. Delete collection");
            Console.WriteLine("23. Read collections from database");

            ProgramHelper.Divider();
            Console.WriteLine("31. Read document");
            Console.WriteLine("32. Delete document");
            Console.WriteLine("33. Insert document");
            Console.WriteLine("34. Update document");

            ProgramHelper.Divider();
            Console.WriteLine("41. Stored procedure");
            Console.WriteLine("42. Trigger");
            Console.WriteLine("43. Use User Defined Function, UDF");

            ProgramHelper.Divider();
            Console.WriteLine("51. Exception");
            ProgramHelper.Divider();

            Console.WriteLine("0. EXIT");
        }
예제 #2
0
        public async Task CreateCollection()
        {
            string databaseName   = ProgramHelper.ReadDatabaseName();
            string collectionName = ProgramHelper.ReadCollectionName();

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

            InfoAboutCollection(documentCollection);
        }
예제 #3
0
        public async Task CreateDatabase()
        {
            string databaseName = ProgramHelper.ReadDatabaseName();

            await _repository.CreateDatabaseAsync(databaseName);

            bool isDatabaseExist = await _repository.CheckIfDatabaseExistAsync(databaseName);

            WriteLine("Database >>> " + databaseName + " <<< created.");
        }
예제 #4
0
 public void InfoAboutCollection(DocumentCollection collection)
 {
     Info("Collection id:\t" + collection.Id);
     WriteLine("Resource id:\t" + collection.ResourceId);
     WriteLine("Self link:\t" + collection.SelfLink);
     WriteLine("Documents link:\t" + collection.DocumentsLink);
     WriteLine("UDFs link:\t" + collection.UserDefinedFunctionsLink);
     WriteLine("Store procedure link:\t" + collection.StoredProceduresLink);
     WriteLine("Triggers link:\t" + collection.TriggersLink);
     WriteLine("Time stamp:\t" + collection.Timestamp);
     ProgramHelper.Divider();
 }
예제 #5
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();
        }
예제 #6
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");
            }
        }
예제 #7
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.");
            }
        }
예제 #8
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);
        }
예제 #9
0
        public void ReadAllCollectionsFromDatabase()
        {
            string databaseName = ProgramHelper.ReadDatabaseName();

            _collectionRepository.ReadAllCollections(databaseName).ForEach(t => InfoAboutCollection(t));
        }
예제 #10
0
        static void Main(string[] args)
        {
            Console.Title = "*** ** *MS Network 18 - Neum* ** ***";

            DIProvider.CreateServiceCollection();

            bool runApp = true;

            while (runApp)
            {
                Console.Clear();
                ProgramHelper.Stars();
                ProgramHelper.Title();
                ProgramHelper.Stars();
                Option();
                Console.Write("> ");
                OptionEnum option = (OptionEnum)Convert.ToInt16(Console.ReadLine());

                switch (option)
                {
                    #region << EXIT >>
                case OptionEnum.EXIT:
                {
                    runApp = false;
                    break;
                }

                    #endregion << EXIT >>

                    #region << Database options >>
                case OptionEnum.CreateDatabase:
                {
                    DatabaseProgram program = new DatabaseProgram();
                    Task.Run(() => program.CreateDatabase()).Wait();
                    break;
                }

                case OptionEnum.DeleteDatabase:
                {
                    DatabaseProgram program = new DatabaseProgram();
                    Task.Run(() => program.DeleteDatabase()).Wait();
                    break;
                }

                case OptionEnum.ListDatabase:
                {
                    DatabaseProgram program = new DatabaseProgram();
                    Task.Run(() => program.ListDatabase()).Wait();
                    break;
                }
                    #endregion << Database options >>

                    #region << Collection options >>
                case OptionEnum.CreateCollection:
                {
                    CollectionProgram program = new CollectionProgram();
                    Task.Run(() => program.CreateCollection()).Wait();
                    break;
                }

                case OptionEnum.DeleteCollection:
                {
                    CollectionProgram program = new CollectionProgram();
                    Task.Run(() => program.DeleteCollection()).Wait();
                    break;
                }

                case OptionEnum.ReadCollectionsOfDatabase:
                {
                    CollectionProgram program = new CollectionProgram();
                    Task.Run(() => program.ReadAllCollectionsFromDatabase()).Wait();
                    break;
                }

                    #endregion << Collection options >>

                    #region << Document options >>

                case OptionEnum.ReadDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.ReadDocument().Wait();
                    break;
                }

                case OptionEnum.DeleteDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.DeleteDocument().Wait();
                    break;
                }

                case OptionEnum.InsertDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.InsertDocument().Wait();
                    break;
                }

                case OptionEnum.UpdateDocument:
                {
                    DocumentProgram program = new DocumentProgram();
                    program.UpdateDocument().Wait();
                    break;
                }

                    #endregion << Document options >>

                    #region << Stored procedure

                case OptionEnum.CallStoredProcedure:
                {
                    StoredProcedureProgram program = new StoredProcedureProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << Stored procedure

                    #region << Trigger >>

                case OptionEnum.ExecuteWithTrigger:
                {
                    TriggerProgram program = new TriggerProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << Trigger >>

                    #region << UDF >>

                case OptionEnum.UseUDF:
                {
                    UDFProgram program = new UDFProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << UDF >>

                    #region << Exception >>

                case OptionEnum.Exception:
                {
                    ExceptionProgram program = new ExceptionProgram();
                    program.Run().Wait();
                    break;
                }

                    #endregion << Exception >>

                    #region << Default >>
                default:
                {
                    runApp = false;
                    break;
                }
                    #endregion << Default >>
                }

                if (runApp)
                {
                    ProgramHelper.Wait();
                }
            }
        }