예제 #1
0
        public async Task <ActionResult> Index()
        {
            WebClient    client  = new WebClient();
            ForcastModel forcast = await client.GetForcast();

            return(View(forcast));
        }
예제 #2
0
        public IList <ForcastModel> GetForcast(string id)
        {
            IList <ForcastModel> forcast = new List <ForcastModel>();

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(SQL_ParkDetails, conn);
                cmd.Parameters.AddWithValue("@parkcode", id);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var forcasts = new ForcastModel
                    {
                        FiveDay     = (int)reader["fivedayforecastvalue"],
                        Low         = (int)reader["low"],
                        High        = (int)reader["high"],
                        Forecast    = (string)reader["forecast"],
                        CelciusLow  = (int)reader["CelciusLow"],
                        CelciusHigh = (int)reader["CelciusHigh"]
                    };
                    forcast.Add(forcasts);
                }
            }
            return(forcast);
        }
예제 #3
0
        public async Task <ForcastModel> GetForcast()
        {
            ForcastModel forcast = new ForcastModel();

            using (var response = await _client.GetAsync("http://localhost:51279/api/CountryModel/1"))
            {
                if (response.IsSuccessStatusCode)
                {
                    string jsonString = await response.Content.ReadAsStringAsync();

                    forcast = _jsonSerializer.Deserialize <ForcastModel>(jsonString);
                }
            }


            return(forcast);
        }
예제 #4
0
        //Veritabanı id ye göre girilen veri setini güncelleme
        public async Task <bool> UpdateTahmin(ObjectId id, ForcastModel g)
        {
            var filter = Builders <ForcastModel> .Filter.Eq(x => x._id, id);

            var update = Builders <ForcastModel> .Update
                         .Set(s => s._id, id)
                         .Set(s => s.GenelDurum, g.GenelDurum);

            try
            {
                UpdateResult actionResult = await ForcastCollection.UpdateOneAsync(filter, update);

                Boolean upd = actionResult.IsAcknowledged && actionResult.ModifiedCount > 0;

                return(actionResult.IsAcknowledged && actionResult.ModifiedCount > 0);
            }
            catch (Exception ex)
            {
                // log or manage the exception
                throw ex;
            }
        }
예제 #5
0
 public async Task Put(string id, [FromBody] ForcastModel value)
 {
     var mongodbservice = new MongoDbServicesForcast("HDTest", "Forcast", "mongodb://127.0.0.1:27017");
     await mongodbservice.UpdateTahmin(new ObjectId(id), value);
 }
예제 #6
0
 public async Task Post([FromBody] ForcastModel tahmin)
 {
     var mongodbservice = new MongoDbServicesForcast("HDTest", "Forcast", "mongodb://127.0.0.1:27017");
     await mongodbservice.InsertTahmin(tahmin);
 }
예제 #7
0
 //Veritabanı İçerik ekleme
 public async Task InsertTahmin(ForcastModel tahmin) => await ForcastCollection.InsertOneAsync(tahmin);