init
This commit is contained in:
27
KretaWeb/Helpers/Extension/ModelStateExtension.cs
Normal file
27
KretaWeb/Helpers/Extension/ModelStateExtension.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user