/// <summary>
 /// Add errors from entity to the model state.
 /// </summary>
 /// <param name="modelState"></param>
 /// <param name="entity"></param>
 public static void AddErrors(this ModelStateDictionary modelState, IErrors errors)
 {
     if (errors.Count > 0)
     {
         errors.EachFull(err => modelState.AddModelError("", err));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Flash all the errors provided.
 /// </summary>
 /// <param name="errors"></param>
 public void FlashErrors(IErrors errors)
 {
     if (errors == null || errors.Count == 0)
     {
         return;
     }
     errors.EachFull(error => this.ModelState.AddModelError("", error));
 }
Exemplo n.º 3
0
        private static string BuildFriendlyError(IErrors errors)
        {
            var buffer = new StringBuilder();

            errors.EachFull(err =>
            {
                if (!string.IsNullOrEmpty(err))
                {
                    if (err.StartsWith("Item #"))
                    {
                        buffer.Append("<br/>");
                    }

                    buffer.Append(err + "<br/>");
                }
            });
            return(buffer.ToString());
        }
 /// <summary>
 /// Flash all the errors provided.
 /// </summary>
 /// <param name="errors"></param>
 public void FlashErrors(IErrors errors)
 {
     if (errors == null || errors.Count == 0) return;
     errors.EachFull(error => this.ModelState.AddModelError("", error));
 }