Beispiel #1
0
 /// <summary>
 /// Only if we are redirecting, transfer model errors to temp data
 /// </summary>
 /// <param name="filterContext"></param>
 /// <remarks>
 /// We do this just before the result executes. This gives ample time to derived controllers to manipulate the model state.
 /// </remarks>
 protected override void OnResultExecuting(ResultExecutingContext filterContext)
 {
     if (filterContext.Result is RedirectToRouteResult && !ModelState.IsValid)
     {
         // Since we are redirecting, ensure that Modelstate errors are transferred to TempData
         var errors = ModelState.SelectMany(p => p.Value.Errors);
         StatusSummaryExtensions.GetErrorList(TempData).AddRange(errors.Select(p => p.Exception == null ? p.ErrorMessage : p.Exception.Message));
     }
     base.OnResultExecuting(filterContext);
 }
Beispiel #2
0
 /// <summary>
 /// Returns the added status messages
 /// </summary>
 /// <returns></returns>
 /// <remarks>
 /// Added by Sharad on 23 May 2012. Allows apps, e.g. Carton Manager, to access the status messages and return them as an ajax list
 /// </remarks>
 protected IEnumerable <string> GetStatusMessages()
 {
     return(StatusSummaryExtensions.GetStatusList(TempData));
 }
Beispiel #3
0
 /// <summary>
 /// Add a status message which can then be displayed appropriately by <see cref="StatusSummaryExtensions.StatusSummary"/>
 /// </summary>
 /// <param name="msg"></param>
 /// <remarks>
 /// public so that attributes like <see cref="AuthorizeExAttribute"/> can access it.
 /// </remarks>
 public void AddStatusMessage(string msg)
 {
     StatusSummaryExtensions.GetStatusList(TempData).Add(msg);
 }