Beispiel #1
0
        public static async Task <DataTools> GetToolsById(int id)
        {
            string nameCollection = InfoMongo.GetElementMongo(ElementMongo.NameTableTools);

            try
            {
                var collection = database.GetCollection <BsonDocument>(nameCollection);
                var filter     = new BsonDocument();
                using (var cursor = await collection.FindAsync(filter))
                {
                    while (await cursor.MoveNextAsync())
                    {
                        var list = cursor.Current.ToList();
                        if (list.Count == 0)
                        {
                            return(null);
                        }

                        foreach (var doc in list)
                        {
                            var temp = BsonSerializer.Deserialize <DataTools>(doc).Id;

                            if (temp == id)
                            {
                                return(BsonSerializer.Deserialize <DataTools>(doc));
                            }
                        }
                    }
                }
            }
            catch { }

            return(null);
        }
Beispiel #2
0
        public static List <DataTools> GetTools()
        {
            string nameCollection = InfoMongo.GetElementMongo(ElementMongo.NameTableTools);
            var    collection     = database.GetCollection <DataTools>(nameCollection).AsQueryable <DataTools>();

            return(collection.ToList());
        }
Beispiel #3
0
        public static List <DataCandlesDay> GetCandlesDayForPeriod(ElementMongo nameTableCandlesPeriod)
        {
            string nameCollection = InfoMongo.GetElementMongo(nameTableCandlesPeriod);
            var    collection     = database.GetCollection <DataCandlesDay>(nameCollection).AsQueryable();

            return(collection.ToList());
        }
Beispiel #4
0
        static APIMongo()
        {
            string connStr = InfoMongo.GetElementMongo(ElementMongo.ConnectionString);
            string nameBD  = InfoMongo.GetElementMongo(ElementMongo.NameBD);

            client   = new MongoClient(connStr);
            database = client.GetDatabase(nameBD);
        }
Beispiel #5
0
        public static async void UpdateTools(DataTools newData)
        {
            string nameCollection = InfoMongo.GetElementMongo(ElementMongo.NameTableTools);

            try
            {
                var collection = database.GetCollection <DataTools>(nameCollection);

                var filter = Builders <DataTools> .Filter.Eq("_id", newData.Id);

                var update = Builders <DataTools> .Update.Set("Name", newData.Name);

                var result = await collection.UpdateOneAsync(filter, update);
            }
            catch { }
        }
Beispiel #6
0
        public static async void UpdateCandlesDay(DataCandlesDay newData, ElementMongo nameTable)
        {
            string nameCollection = InfoMongo.GetElementMongo(nameTable);

            try
            {
                var collection = database.GetCollection <DataCandlesDay>(nameCollection);

                var filter = Builders <DataCandlesDay> .Filter.Eq("_id", newData.Id);

                var update = Builders <DataCandlesDay> .Update.Set("ArrayPrices", newData.ArrayPrices);

                var result = await collection.UpdateOneAsync(filter, update);
            }
            catch { }
        }
Beispiel #7
0
 public static async void SetCandles(BsonDocument doc, ElementMongo nameTable)
 {
     string nameCollection = InfoMongo.GetElementMongo(nameTable);
     var    collection     = database.GetCollection <BsonDocument>(nameCollection);
     await collection.InsertOneAsync(doc);
 }
Beispiel #8
0
 public static void Dell()
 {
     database.DropCollection(InfoMongo.GetElementMongo(ElementMongo.NameTableGlass));
 }