public UserRepository(string connection)
        {
            if (string.IsNullOrWhiteSpace(connection))
            {
                connection = "mongodb://*****:*****@localhost:27017";
            }
            _dbClient   = new MongoDB.Driver.MongoClient(connection);
            _database   = _dbClient.GetDatabase("dashboard");
            _collection = _database.GetCollection <User>("User");

            Widgets.IWidget Weather = new Widgets.WeatherConditions();
            Weather.Intake("Paris,fr");
            Weather.Invoke(new User());
        }
Ejemplo n.º 2
0
        public ServiceRepository(string connection)
        {
            if (string.IsNullOrWhiteSpace(connection))
            {
                connection = "mongodb://*****:*****@localhost:27017";
            }
            _dbClient   = new MongoDB.Driver.MongoClient(connection);
            _database   = _dbClient.GetDatabase("dashboard");
            _collection = _database.GetCollection <Service>("Service");
            long count = _collection.CountDocuments(new BsonDocument());

            if (count == 0)
            {
                Dashboard.Models.WidgetRepository widgets = new WidgetRepository("");
                widgets.Drop();
                _collection.DeleteMany(new BsonDocument());
                Dashboard.Models.Service service = new Service();
                service.Name = "weather";
                IWidget widget = new Widgets.WeatherConditions();
                widgets.Add(widget);
                service.Widgets.Add(widget);
                _collection.InsertOne(service);

                service      = new Service();
                service.Name = "rss";
                widget       = new Widgets.RssFeed();
                widgets.Add(widget);
                service.Widgets.Add(widget);
                _collection.InsertOne(service);

                service      = new Service();
                service.Name = "tempconversion";
                widget       = new Widgets.TempUnitConversion();
                widgets.Add(widget);
                service.Widgets.Add(widget);
                _collection.InsertOne(service);

                service      = new Service();
                service.Name = "twittertweets";
                widget       = new Widgets.Twitter();
                widgets.Add(widget);
                service.Widgets.Add(widget);
                _collection.InsertOne(service);
            }
        }