-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathShortListForm.ascx.vb
executable file
·136 lines (100 loc) · 5.1 KB
/
ShortListForm.ascx.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Users
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Namespace Ventrian.PropertyAgent
Partial Public Class ShortListForm
Inherits PropertyAgentControl
#Region " Private Properties"
Private ReadOnly Property ResourceFile() As String
Get
Return "~/DesktopModules/PropertyAgent/App_LocalResources/ShortListForm"
End Get
End Property
Private ReadOnly Property UserID() As Integer
Get
Dim ID As Integer = Null.NullInteger
If (Request.IsAuthenticated) Then
Dim objUser As UserInfo = UserController.GetCurrentUserInfo()
If (objUser IsNot Nothing) Then
ID = objUser.UserID
End If
End If
Return ID
End Get
End Property
Private ReadOnly Property UserKey() As String
Get
If (Request.IsAuthenticated) Then
Return ""
Else
If (Request.Cookies("ShortList-PA-" & CurrentProperty.ModuleID.ToString()) Is Nothing) Then
Response.Cookies("ShortList-PA-" & CurrentProperty.ModuleID.ToString()).Value = Guid.NewGuid().ToString()
End If
Return Request.Cookies("ShortList-PA-" & CurrentProperty.ModuleID.ToString()).Value
End If
End Get
End Property
#End Region
#Region " Event Handlers "
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim shortListLabel As String = Constants.SHORTLIST_LABEL_SETTING_DEFAULT
If (PropertyAgentBase IsNot Nothing) Then
shortListLabel = PropertySettings.ShortListLabel
cmdAddShortList.CssClass = PropertySettings.ButtonClass
cmdRemoveShortList.CssClass = PropertySettings.ButtonClass
Else
If (PropertyAgentLatestBase IsNot Nothing) Then
shortListLabel = PropertyAgentLatestBase.PropertySettings.ShortListLabel
cmdAddShortList.CssClass = PropertyAgentLatestBase.PropertySettings.ButtonClass
cmdRemoveShortList.CssClass = PropertyAgentLatestBase.PropertySettings.ButtonClass
End If
End If
cmdAddShortList.Text = Localization.GetString("cmdAddShortList", ResourceFile)
cmdAddShortList.Text = cmdAddShortList.Text.Replace("[SHORTLIST]", shortListLabel)
cmdRemoveShortList.Text = Localization.GetString("cmdRemoveShortList", ResourceFile)
cmdRemoveShortList.Text = cmdRemoveShortList.Text.Replace("[SHORTLIST]", shortListLabel)
Dim objShortListController As New ShortListController()
Dim objShortList As ShortListInfo = objShortListController.Get(CurrentProperty.PropertyID, UserID, UserKey)
If (objShortList Is Nothing) Then
' Add Item
cmdRemoveShortList.Visible = False
Else
' Remove Item
cmdAddShortList.Visible = False
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdAddShortList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddShortList.Click
Try
Dim objShortList As New ShortListInfo()
objShortList.CreateDate = DateTime.Now
objShortList.PropertyID = CurrentProperty.PropertyID
objShortList.UserID = UserID
objShortList.UserKey = UserKey
Dim objShortListController As New ShortListController()
objShortListController.Add(objShortList)
cmdRemoveShortList.Visible = True
cmdAddShortList.Visible = False
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
Response.Redirect(Request.RawUrl)
End Sub
Private Sub cmdRemoveShortList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemoveShortList.Click
Try
Dim objShortListController As New ShortListController()
objShortListController.Delete(CurrentProperty.PropertyID, UserID, UserKey)
cmdRemoveShortList.Visible = False
cmdAddShortList.Visible = True
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
Response.Redirect(Request.RawUrl)
End Sub
#End Region
End Class
End Namespace