-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor setup to Initializer filters for menu setup and setting Curr…
…entUser
- Loading branch information
Maher Hawash
committed
Apr 16, 2012
1 parent
3681b41
commit 1e17240
Showing
13 changed files
with
102 additions
and
107 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Hometastic/Hometastic/Controllers/ApplicationController.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Imports Hometastic.Models | ||
Namespace Hometastic | ||
Public Class ApplicationController | ||
Inherits System.Web.Mvc.Controller | ||
Dim m_CurrentUser As MVNetBase = Nothing | ||
|
||
Function CurrentUser() | ||
If m_CurrentUser Is Nothing Then | ||
m_CurrentUser = Session("CurrentUser") | ||
End If | ||
Return m_CurrentUser | ||
End Function | ||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
Imports System.Collections | ||
Imports Hometastic.Models | ||
|
||
Public Class HomeController | ||
Inherits System.Web.Mvc.Controller | ||
Sub SetupMenu() | ||
ViewBag.Menu = {({"My Account", "/Home/Index"}), | ||
({"Services", "/Home/Services"}), | ||
({"Contact Us", "/Home/ContactUs"}) | ||
} | ||
End Sub | ||
|
||
Function Index(ByVal query As String) As ActionResult | ||
Dim s As String = HttpContext.Request.RequestContext.RouteData.Values("path") | ||
If s Is Nothing Then | ||
s = "Index" | ||
End If | ||
|
||
SetupMenu() | ||
Return View(s) | ||
End Function | ||
|
||
Public Function LogOn() As ActionResult | ||
SetupMenu() | ||
Return View("Index") | ||
End Function | ||
<HttpPost()> _ | ||
Public Function LogOn(ByVal collection As FormCollection) As ActionResult | ||
|
||
If Account.Authenticate(collection("mgmtCoId"), collection("password"), collection("clientNumber"), collection("userType")) Then | ||
Return RedirectToAction("Index", collection("userType")) | ||
End If | ||
|
||
Return RedirectToAction("LogOn") | ||
End Function | ||
|
||
<HttpPost()> _ | ||
Public Function ContactUs(ByVal collection As FormCollection) As ActionResult | ||
|
||
Return View() | ||
End Function | ||
|
||
End Class | ||
Namespace Hometastic | ||
Public Class HomeController | ||
Inherits ApplicationController | ||
|
||
Function Index(ByVal query As String) As ActionResult | ||
Dim s As String = HttpContext.Request.RequestContext.RouteData.Values("path") | ||
If s Is Nothing Then | ||
s = "Index" | ||
End If | ||
|
||
Return View(s) | ||
End Function | ||
|
||
Public Function LogOn() As ActionResult | ||
Return View("Index") | ||
End Function | ||
<HttpPost()> _ | ||
Public Function LogOn(ByVal collection As FormCollection) As ActionResult | ||
|
||
If Account.Authenticate(collection("mgmtCoId"), collection("password"), collection("clientNumber"), collection("userType")) Then | ||
Return RedirectToAction("Index", collection("userType")) | ||
End If | ||
|
||
Return RedirectToAction("LogOn") | ||
End Function | ||
|
||
<HttpPost()> _ | ||
Public Function ContactUs(ByVal collection As FormCollection) As ActionResult | ||
|
||
Return View() | ||
End Function | ||
|
||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Imports MvcFlash.Core | ||
|
||
Namespace Models | ||
' This filter limits controller actions to users who log in as a management company. | ||
' In web.config, the section defines where it should redirect on failed authentication: | ||
' <authentication mode="Forms"> | ||
' <forms defaultUrl="/" loginUrl="/" timeout="2880" /> | ||
' </authentication> | ||
' The filters are attached to the controller through the ActionFilterProvider class in global.asax . | ||
' | ||
Public Class ManagementCompanyInitializeFilter | ||
Inherits ActionFilterAttribute | ||
Public Overrides Sub OnActionExecuting(ByVal filterContext As ActionExecutingContext) | ||
filterContext.Controller.ViewBag.Menu = {({"My Account", "/ManagementCompany/Index"}), | ||
({"Manage Site", "/ManagementCompany/Edit"}), | ||
({"News", "/News/Index"}), | ||
({"Q&A", "/ManagementCompany/Survey"}) | ||
} | ||
Account.Authenticate("6400", "pmsi", "", "ManagementCompany") | ||
End Sub | ||
End Class | ||
|
||
Public Class HoaInitializeFilter | ||
Inherits ActionFilterAttribute | ||
Public Overrides Sub OnActionExecuting(ByVal filterContext As ActionExecutingContext) | ||
filterContext.Controller.ViewBag.Menu = {({"My Account", "/ManagementCompany/Index"}), | ||
({"Manage Site", "/ManagementCompany/Edit"}), | ||
({"News", "/News/Index"}), | ||
({"This and That", "/ManagementCompany/Survey"}) | ||
} | ||
End Sub | ||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters