-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeController.vb
51 lines (42 loc) · 2.19 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
49
50
51
Imports Microsoft.VisualBasic
Imports System
Imports System.Linq
Imports System.Web.Mvc
Imports DevExpress.Web.Mvc
Imports SchedulerFilterResourcesDataLevelMvc.Code
Imports SchedulerFilterResourcesDataLevelMvc.Models
Imports System.Collections.Generic
Namespace SchedulerFilterResourcesDataLevelMvc
Public Class HomeController
Inherits Controller
Public Function Index() As ActionResult
Return View(SchedulerDataHelper.DataObject)
End Function
Public Function SchedulerPartial() As ActionResult
Return PartialView("SchedulerPartial", SchedulerDataHelper.GetDataObject(GetSelectedResourceIds()))
End Function
Public Function EditAppointment() As ActionResult
UpdateAppointment()
Return PartialView("SchedulerPartial", SchedulerDataHelper.GetDataObject(GetSelectedResourceIds()))
End Function
Private Function GetSelectedResourceIds() As List(Of Integer)
Dim req As String = IIf(Request.Params("SelectedResources") IsNot Nothing, Request.Params("SelectedResources"), String.Empty).ToString()
If req Is String.Empty Then
Return New List(Of Integer)
End If
Return CType(IIf(req <> String.Empty, req.Split(","c).Select(Function(n) Convert.ToInt32(n)).ToList(), New List(Of Integer)()), List(Of Integer))
End Function
Private Shared Sub UpdateAppointment()
Dim insertedAppt As CarScheduling = SchedulerExtension.GetAppointmentToInsert(Of CarScheduling)(SchedulerHelper.Settings, SchedulerDataHelper.GetAppointments(), SchedulerDataHelper.GetResources())
SchedulerDataHelper.InsertAppointment(insertedAppt)
Dim updatedAppt() As CarScheduling = SchedulerExtension.GetAppointmentsToUpdate(Of CarScheduling)(SchedulerHelper.Settings, SchedulerDataHelper.GetAppointments(), SchedulerDataHelper.GetResources())
For Each appt In updatedAppt
SchedulerDataHelper.UpdateAppointment(appt)
Next appt
Dim removedAppt() As CarScheduling = SchedulerExtension.GetAppointmentsToRemove(Of CarScheduling)(SchedulerHelper.Settings, SchedulerDataHelper.GetAppointments(), SchedulerDataHelper.GetResources())
For Each appt In removedAppt
SchedulerDataHelper.RemoveAppointment(appt)
Next appt
End Sub
End Class
End Namespace