public async Task <ActionResult <int> > AddCostAttributes()
        {
            const string logMessage = "Add costattributes, ";
            const int    amount     = 200;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            List <CalculatedElementData> calculatedElementDatas = TestClass.FillElementList(amount);

            sw.Stop();
            Log.Information("FillElementList {0} ms", sw.ElapsedMilliseconds);

            try
            {
                Log.Information($"{logMessage}begin");
                await _mongoService.Add(calculatedElementDatas);

                Log.Information($"{logMessage}end");

                return(Ok());
            }
            catch (Exception ex)
            {
                Log.Error($"{logMessage}error, {ex.Message}");
                return(BadRequest());
            }
        }
예제 #2
0
        public IEnumerable <WeatherForecast> Get()
        {
            DatabaseSettings databaseSettings = new DatabaseSettings()
            {
                ConnectionString = "mongodb://192.168.130.133:27017",
                DatabaseName     = "test"
            };

            var service = new MongoService <StudentModel>(databaseSettings, "student");
            var model   = new StudentModel()
            {
                Age  = 12,
                Name = "test"
            };

            service.Add(model);


            var rng = new Random();

            return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
                   .ToArray());
        }
        public void AddTest()
        {
            MongoService service = new MongoService();

            MongoDbUtil.Instance().Drop();
            service.Add(new WeatherData()
            {
                Country       = "BE",
                Temperature   = 12.5,
                Speed         = 10.2,
                City          = "Ghent",
                Pressure      = 12,
                WindSpeed     = 5,
                Id            = Guid.NewGuid(),
                Humidty       = 5,
                WindDirection = "NE",
                UpdateWeather = DateTime.Now
            });
            Assert.IsTrue(service.GetWeatherDatas().Count() == 1);
        }
예제 #4
0
        public void StoreDataWeather(string postCode, string country)
        {
            var bulk = _weatherWebRetrieverService.GetWeatherDataNow(postCode, country);

            _dataRepo.Add(bulk);
        }