-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHomeController.cs
45 lines (39 loc) · 1.44 KB
/
HomeController.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
using DevExpress.Web.Mvc;
using DXWebApplication1.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace DXWebApplication1.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index() {
return View(PersonsList.GetPersons());
}
public ActionResult GridViewPartial() {
return PartialView(PersonsList.GetPersons());
}
[HttpPost, ValidateInput(false)]
public ActionResult BatchEditingUpdateModelPerson(MVCxGridViewBatchUpdateValues<Person, int> batchValues) {
foreach(var person in batchValues.Update) {
if(batchValues.IsValid(person))
PersonsList.UpdatePerson(person);
else
batchValues.SetErrorText(person, "Correct validation errors");
}
foreach(var person in batchValues.Insert) {
if(batchValues.IsValid(person))
PersonsList.AddPerson(person);
else
batchValues.SetErrorText(person, "Correct validation errors");
}
foreach (var personID in batchValues.DeleteKeys) {
PersonsList.DeletePerson(personID);
}
return PartialView("GridViewPartial", PersonsList.GetPersons());
}
}
}