public ActionResult Search(string S = "") { try { if (S != "") { NewsEntity.Models.Search theSearch = new NewsEntity.Models.Search(); theSearch.S = S; theSearch.Save(); var NewsView = new NewsMain(false, S); return(View(NewsView)); } return(RedirectToAction("Index", "Home")); } catch (Exception ex) { string err = ex.Message; if (ex.InnerException != null) { err += ": " + ex.InnerException.Message; } var theView = new Models.NewsMain(false); theView.Error = err; return(View(theView)); } }
public Meteodata() { try { MeteoService.HydroServiceClient theMeteo = new MeteoService.HydroServiceClient(); var SiteId = theMeteo.GetSite("31721", 1); if (SiteId != null) { var values = theMeteo.GetDataValuesLocal(SiteId.SiteId, DateTime.UtcNow.AddHours(-1), DateTime.Now.AddHours(12), 5, null, null, 1); if (values == null || values.Count == 0) { throw new Exception("Данные по температуре не отобраны"); } this.Temperature = values.Last().Value; this.Date = values.Last().DateUTC.AddHours(10); values = theMeteo.GetDataValuesLocal(SiteId.SiteId, DateTime.UtcNow.AddHours(-1), DateTime.Now.AddHours(12), 1, null, null, 1); if (values == null || values.Count == 0) { throw new Exception("Данные по направлению ветра не отобраны"); } this.Wind = values.Last().Value; values = theMeteo.GetDataValuesLocal(SiteId.SiteId, DateTime.UtcNow.AddHours(-1), DateTime.Now.AddHours(12), 7, null, null, 1); if (values == null || values.Count == 0) { throw new Exception("Данные по скорости ветра не отобраны"); } this.WindSpeed = values.Last().Value; } } catch (Exception ex) { string err = ex.Message; if (ex.InnerException != null) { err += ": " + ex.InnerException.Message; } var theView = new Models.NewsMain(false); Error = err; } }
// // GET: /Home/ public ActionResult Index() { try { var theView = new Models.NewsMain(); return(View(theView)); } catch (Exception ex) { string err = ex.Message; if (ex.InnerException != null) { err += ": " + ex.InnerException.Message; } var theView = new Models.NewsMain(false); theView.Error = err; return(View(theView)); } }