/// <summary> /// Constructeur complet /// </summary> /// <param name="controller"></param> public LayoutManager(Controller controller) { this._temp = controller.TempData; try { this.ActionName = controller.RouteData.GetRequiredString("action"); this.ControllerName = controller.RouteData.GetRequiredString("controller"); this.Controller = controller; } catch { } }
public static bool IsBadRequest(HttpStatusCode statusCode, System.Web.Mvc.TempDataDictionary tempData, string Message = "Error: Bad Request") { if (statusCode == System.Net.HttpStatusCode.BadRequest) { tempData["Message"] = Message; tempData["MessageColour"] = "danger"; return(true); } else { return(false); } }
public static bool IsUnAuthorized(HttpStatusCode statusCode, System.Web.Mvc.TempDataDictionary tempData, string Message = "Error: Not Authorized") { if (statusCode == System.Net.HttpStatusCode.Unauthorized) { tempData["Message"] = Message; tempData["MessageColour"] = "danger"; return(true); } else { return(false); } }
public static bool IsInternalServerError(HttpStatusCode statusCode, System.Web.Mvc.TempDataDictionary tempData, string Message = "Internal Server Error, try again later") { if (statusCode == System.Net.HttpStatusCode.InternalServerError) { tempData["Message"] = Message; tempData["MessageColour"] = "danger"; return(true); } else { return(false); } }
public static bool IdIsInvalid(int?id, System.Web.Mvc.TempDataDictionary tempData, string Message = "Improper Id") { if (id is null) { tempData["Message"] = Message; tempData["MessageColour"] = "danger"; return(true); } else { return(false); } }
public static bool IsNotFound(HttpStatusCode statusCode, System.Web.Mvc.TempDataDictionary tempData, string Message = "Item not found") { if (statusCode == System.Net.HttpStatusCode.NotFound) { tempData["Message"] = Message; tempData["MessageColour"] = "danger"; return(true); } else { return(false); } }
public static object TempDataU(string keyName, System.Web.Mvc.TempDataDictionary dict, object defaultValue) { var retV = defaultValue; try { var keyValue = dict[keyName]; if (keyValue != null) { retV = keyValue; } } catch { } return(retV); }
public static string RenderPartialViewToString(nameFile.ControllerContext controllerContext, string viewName, object model) { nameFile.ViewDataDictionary ViewData = new nameFile.ViewDataDictionary(model); nameFile.TempDataDictionary TempData = new nameFile.TempDataDictionary(); if (string.IsNullOrEmpty(viewName)) { viewName = controllerContext.RouteData.GetRequiredString("action"); } ViewData.Model = model; using (StringWriter sw = new StringWriter()) { nameFile.ViewEngineResult viewResult = nameFile.ViewEngines.Engines.FindPartialView(controllerContext, viewName); nameFile.ViewContext viewContext = new nameFile.ViewContext(controllerContext, viewResult.View, ViewData, TempData, sw); viewResult.View.Render(viewContext, sw); return(sw.GetStringBuilder().ToString()); } }
public LayoutManager(HtmlHelper html) { this._temp = html.ViewContext.Controller.TempData; }
public static string TempData(string keyName, System.Web.Mvc.TempDataDictionary dict, string defaultValue = "") { return(TempDataU(keyName, dict, defaultValue).ToString()); }
public TempDataDictionaryEnumerator(TempDataDictionary tempData) { _tempData = tempData; _enumerator = _tempData._data.GetEnumerator(); }
public ViewContext(ControllerContext controllerContext, IView view, ViewDataDictionary viewData, TempDataDictionary tempData, TextWriter writer) : base(controllerContext) { if (controllerContext == null) { throw new ArgumentNullException("controllerContext"); } if (view == null) { throw new ArgumentNullException("view"); } if (viewData == null) { throw new ArgumentNullException("viewData"); } if (tempData == null) { throw new ArgumentNullException("tempData"); } if (writer == null) { throw new ArgumentNullException("writer"); } View = view; ViewData = viewData; Writer = writer; TempData = tempData; }