-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeController.cs
49 lines (42 loc) · 1.69 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
46
47
48
49
using DevExpress.Web.Mvc;
using DXWebApplication1.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace DevExpressMvcApplication1.Controllers {
public class HomeController : Controller {
PersonsList list = new PersonsList();
public ActionResult Index() {
return View(list.GetPersons());
}
public ActionResult GridViewPartial() {
return PartialView(list.GetPersons());
}
[HttpPost, ValidateInput(false)]
public ActionResult EditingAddNew([ModelBinder(typeof(DevExpressEditorsBinder))]Person personInfo) {
if (ModelState.IsValid)
list.AddPerson(personInfo);
return PartialView("GridViewPartial", list.GetPersons());
}
[HttpPost, ValidateInput(false)]
public ActionResult EditingUpdate([ModelBinder(typeof(DevExpressEditorsBinder))]Person personInfo) {
if (ModelState.IsValid)
list.UpdatePerson(personInfo);
return PartialView("GridViewPartial", list.GetPersons());
}
private void UpdateModelLastNameValue(Person personInfo) {
if (Request.Params["FirstName"].Contains("text"))
personInfo.LastName = Request.Params["cmb"];
else
personInfo.LastName = Request.Params["txt"];
ModelState.Clear();
UpdateModel<Person>(personInfo);
}
public ActionResult EditingDelete([ModelBinder(typeof(DevExpressEditorsBinder))]int personId) {
list.DeletePerson(personId);
return PartialView("GridViewPartial", list.GetPersons());
}
}
}