public void CloseEvent() { CWeather CurrentWeather = new CWeather(); // dynamic CurrentWeather; try { using (var wc = new WebClient()) { var jsonString = "http://api.wunderground.com/api/37f4201157f6db0a/conditions/q/WI/Appleton.json"; string rawJSON = wc.DownloadString(jsonString); CurrentWeather = JsonConvert.DeserializeObject <CWeather>(rawJSON); } LFGuestSystemEntities oDc = new LFGuestSystemEntities(); var item = (from p in oDc.tblEvents where p.EventID == this.EventID select p).FirstOrDefault(); if (item != null) { //item.EventID = this.EventID; //item.Date = this.Date; item.MealCount = this.ChildTray + this.AdultTray; item.VolunteerCount = this.VolunteerCount; //item.SiteID = this.SiteID; item.Temp = Convert.ToDecimal(CurrentWeather.CurrentObservation.TempF); item.WeatherDesc = CurrentWeather.CurrentObservation.Weather; item.ChildTray = this.ChildTray; item.AdultTray = this.AdultTray; item.IsActive = false; item.Comments = this.Comments; oDc.SaveChanges(); } CHistory archive = new CHistory(); archive.Insert(EventID); } catch (Exception ex) { throw ex; } }
public static string ToJson(this CWeather self) => JsonConvert.SerializeObject(self, CheckInManager.BL.Converter.Settings);