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 }))); }
private static PrefixedRouteAdder AddControllersWithPrefix(MethodArg method, RouteArg prefix) { void Adder(params PartialController[] controllers) { Controller[] prefixedControllers = new Controller[controllers.Length]; for (int i = 0; i < controllers.Length; i++) { PartialController beforePrefix = controllers[i]; if (beforePrefix.Route == null) { throw new ArgumentException("Cannot use a RoutePatternMatch route with the prefix adder."); } prefixedControllers[i] = (method.Value, prefix.Value + beforePrefix.Route.TrimStart('/', '\\'), beforePrefix.Callback); } Routes(prefixedControllers); } return(Adder); }
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)); } }