コード例 #1
0
 /// <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 { }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
ファイル: Utils.cs プロジェクト: mvali/RegisterMVC
    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);
    }
コード例 #8
0
        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());
            }
        }
コード例 #9
0
 public LayoutManager(HtmlHelper html)
 {
     this._temp = html.ViewContext.Controller.TempData;
 }
コード例 #10
0
ファイル: Utils.cs プロジェクト: mvali/RegisterMVC
 public static string TempData(string keyName, System.Web.Mvc.TempDataDictionary dict, string defaultValue = "")
 {
     return(TempDataU(keyName, dict, defaultValue).ToString());
 }
コード例 #11
0
 public TempDataDictionaryEnumerator(TempDataDictionary tempData)
 {
     _tempData   = tempData;
     _enumerator = _tempData._data.GetEnumerator();
 }
コード例 #12
0
        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;
        }