Ejemplo n.º 1
0
        private static bool InitializeMongo()
        {
            MongoUtilsTopicObj   = new MongoDBUtils <Topic>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);
            MongoUtilsCommentObj = new MongoDBUtils <Comment>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);
            MongoUtilsUserObj    = new MongoDBUtils <User>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);

            // Sanit Check
            if (!MongoUtilsTopicObj.IsValidMongoData(Config))
            {
                return(false);
            }

            // Invalid Collection?
            if (!MongoUtilsTopicObj.CollectionExistsAsync(Config.MongoCollection).Result ||
                !MongoUtilsCommentObj.CollectionExistsAsync(CommentsCollection).Result ||
                !MongoUtilsUserObj.CollectionExistsAsync(UsersCollection).Result)
            {
                return(false);
            }

            // Open the Connection
            MongoUtilsTopicObj.GetCollection(Config.MongoCollection);
            MongoUtilsCommentObj.GetCollection(CommentsCollection);
            MongoUtilsUserObj.GetCollection(UsersCollection);

            return(true);
        }
        private static bool InitializeMongo()
        {
            MongoUtilsObj = new MongoDBUtils <Section>(Config.MongoUser, Config.MongoPassword, Config.MongoAddress, Config.MongoDatabase);

            // Sanit Check
            if (!MongoUtilsObj.IsValidMongoData(Config))
            {
                return(false);
            }

            // Is There no collection?
            if (!MongoUtilsObj.CollectionExistsAsync(Config.MongoCollection).Result)
            {
                MongoUtilsObj.CreateCollection(Config.MongoCollection);
            }

            return(true);
        }