-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHomeController.vb
48 lines (45 loc) · 1.38 KB
/
HomeController.vb
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
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.Mvc
Imports DevExpress.Web.Mvc
Imports Models
Namespace GridViewBatchEdit.Controllers
Public Class HomeController
Inherits Controller
Public Function Index() As ActionResult
Return View()
End Function
<ValidateInput(False)> _
Public Function GridViewPartial() As ActionResult
Return PartialView("_GridViewPartial", BatchEditRepository.GridData)
End Function
<HttpPost, ValidateInput(False)> _
Public Function BatchUpdatePartial(ByVal batchValues As MVCxGridViewBatchUpdateValues(Of GridDataItem, Integer)) As ActionResult
If ModelState.IsValid Then
Try
For Each item In batchValues.Insert
If batchValues.IsValid(item) Then
BatchEditRepository.InsertNewItem(item)
End If
Next item
For Each item In batchValues.Update
If batchValues.IsValid(item) Then
BatchEditRepository.UpdateItem(item)
End If
Next item
For Each itemKey In batchValues.DeleteKeys
BatchEditRepository.DeleteItem(itemKey)
Next itemKey
Catch e As Exception
ViewData("EditError") = e.Message
End Try
Else
ViewData("EditError") = "Please, correct all errors."
End If
Return PartialView("_GridViewPartial", BatchEditRepository.GridData)
End Function
End Class
End Namespace