-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNullableDataTablesModelBinder.cs
More file actions
33 lines (30 loc) · 1.1 KB
/
NullableDataTablesModelBinder.cs
File metadata and controls
33 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Linq;
using System.Web.Mvc;
namespace RootHelpers.Datatables
{
public class NullableDataTablesModelBinder : IModelBinder
{
private DataTablesModelBinder dataTablesModelBinder = null;
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
DataTablesParam obj = new DataTablesParam();
var request = controllerContext.HttpContext.Request.Params;
if (request.AllKeys.Contains("iDisplayStart")
&& request.AllKeys.Contains("iDisplayLength")
&& request.AllKeys.Contains("iColumns")
&& request.AllKeys.Contains("iSortingCols")
&& request.AllKeys.Contains("sEcho"))
{
if (dataTablesModelBinder == null)
{
dataTablesModelBinder = new DataTablesModelBinder();
}
return dataTablesModelBinder.BindModel(controllerContext, bindingContext);
}
else
{
return null;
}
}
}
}