Exemplo n.º 1
0
        static async Task <HtmlString> Helper(this HtmlHelper helper, HelperModel.HelperModelType type, string text = null, string title = null, string url = null)
        {
            var viewEngine = helper.ViewContext.HttpContext.RequestServices.GetService(typeof(ICompositeViewEngine)) as ICompositeViewEngine;
            var controller = new PartialController(viewEngine);

            return(new HtmlString(await controller.RenderPartialViewToString("Helpers", new HelperModel {
                Type = type, Text = text, Title = title, Url = url
            })));
        }
Exemplo n.º 2
0
 public JsonResult ChangeWeathersSingleIndex(int Id_Country, int Id_Provincia)
 {
     if (Id_Country != 0 && Id_Provincia != 0)
     {
         var WeathersJsonSingle = America.GetWeathers(Id_Province: Id_Provincia);
         var WeathersPrincipal  = JsonConvert.DeserializeObject <List <Weather> >(WeathersJsonSingle).Where(x => x.Date == DateTime.Today).FirstOrDefault();
         var WeathersJson       = America.GetWeathersWeek(Id_Province: Id_Provincia);
         var Weathers           = JsonConvert.DeserializeObject <List <Weather> >(WeathersJson);
         if (WeathersPrincipal != null)
         {
             var HtmlPartial     = PartialController.RenderPartialViewToString(this, "WeatherPartial", WeathersPrincipal);
             var HtmlListPartial = PartialController.RenderPartialViewToString(this, "WeatherListPartial", Weathers);
             return(Json(new { Key = true, Weather = HtmlPartial, ListWeather = HtmlListPartial }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json("", JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json("", JsonRequestBehavior.AllowGet));
     }
 }