27 lines
893 B
C#
27 lines
893 B
C#
using System.Collections.Generic;
|
|
using System.Web.Http.ModelBinding;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class ModelStateExtension
|
|
{
|
|
public static void AddRange(this ModelStateDictionary modelStateDictionary, Dictionary<string, string> dictionary)
|
|
{
|
|
foreach (KeyValuePair<string, string> item in dictionary)
|
|
{
|
|
modelStateDictionary.AddModelError(item.Key, item.Value);
|
|
}
|
|
}
|
|
|
|
public static void AddRange(this ModelStateDictionary modelStateDictionary, Dictionary<string, List<string>> dictionary)
|
|
{
|
|
foreach (KeyValuePair<string, List<string>> item in dictionary)
|
|
{
|
|
foreach (string value in item.Value)
|
|
{
|
|
modelStateDictionary.AddModelError(item.Key, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|