-
Notifications
You must be signed in to change notification settings - Fork 1
/
HomeController.vb
46 lines (45 loc) · 1.85 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
Imports Microsoft.VisualBasic
Imports System.Web.Mvc
Imports E4425.Models
Imports DevExpress.Web.Mvc
Imports System.Linq
Namespace E4425.Controllers
Public Class HomeController
Inherits Controller
Private entity As New WorldCitiesEntities()
Public Function Index() As ActionResult
Return View(entity.Customers.ToList())
End Function
Public Function GridViewPartial() As ActionResult
Return PartialView(entity.Customers.ToList())
End Function
Public Function GridViewEditPartial(ByVal modifiedValues As MVCxGridViewBatchUpdateValues(Of Customer, Integer)) As ActionResult
For Each customerInfo In modifiedValues.Insert
If modifiedValues.IsValid(customerInfo) Then
entity.Customers.Add(customerInfo)
End If
Next customerInfo
For Each customerInfo In modifiedValues.Update
If modifiedValues.IsValid(customerInfo) Then
entity.Customers.Attach(customerInfo)
Dim entry = entity.Entry(customerInfo)
entry.Property(Function(e) e.CityId).IsModified = True
entry.Property(Function(e) e.CountryId).IsModified = True
entry.Property(Function(e) e.CustomerName).IsModified = True
End If
Next customerInfo
For Each customerID In modifiedValues.DeleteKeys
entity.Customers.Remove(entity.Customers.Find(customerID))
Next customerID
'uncomment the next line to enable database updates
'entity.SaveChanges()
Return PartialView("GridViewPartial", entity.Customers.ToList())
End Function
Public Function ComboBoxCountryPartial() As ActionResult
Return GridViewExtension.GetComboBoxCallbackResult(ComboBoxPropertiesProvider.Current.CountryComboBoxProperties)
End Function
Public Function ComboBoxCityPartial() As ActionResult
Return GridViewExtension.GetComboBoxCallbackResult(ComboBoxPropertiesProvider.Current.CityComboBoxProperties)
End Function
End Class
End Namespace