Advertisement
gyrospring

✒ 0007.0043 VS2019 VB MVC Razor MachinesController.vb

Apr 21st, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. Public Class MachinesController
  2.  
  3.  
  4.  
  5.  
  6. Inherits System.Web.Mvc.Controller
  7.  
  8.  
  9.  
  10.  
  11. Function Index(ByVal Id As String, ByVal Path As String) As ActionResult
  12.  
  13.  
  14. Dim PathParsed As String = ""
  15. Dim FileName As String = ""
  16. Dim PathLeft As String = "~/views/machines/"
  17. Dim ViewPath As String = ""
  18.  
  19. If Id = "" Then Return View("~/views/home/machines.vbhtml")
  20.  
  21. If Path <> "" Then
  22.  
  23. PathParsed = Path.ToLower
  24.  
  25. If PathParsed.EndsWith("/") = True Then PathParsed = PathParsed.Substring(1, PathParsed.Length - 1)
  26.  
  27. End If
  28.  
  29. Select Case Id.ToLower
  30.  
  31. Case "pc"
  32.  
  33. If PathParsed = "windows" Then
  34.  
  35. FileName = PathParsed
  36.  
  37. ElseIf PathParsed = "windows/desktop" Then
  38.  
  39. FileName = PathParsed
  40.  
  41. ElseIf PathParsed = "windows/tv" Then
  42.  
  43. FileName = PathParsed
  44.  
  45. End If
  46.  
  47. If FileName <> "" Then
  48.  
  49. PathLeft += Id & "/"
  50.  
  51. Else
  52.  
  53. If PathParsed = "" Then FileName = Id
  54.  
  55. End If
  56.  
  57. Case "phone"
  58.  
  59. If FileName <> "" Then
  60.  
  61. PathLeft += Id & "/"
  62.  
  63. Else
  64.  
  65. If PathParsed = "" Then FileName = Id
  66.  
  67. End If
  68.  
  69. Case "tablet"
  70.  
  71. If PathParsed = "ereader" Then
  72.  
  73. FileName = PathParsed
  74.  
  75. ElseIf PathParsed = "10inch" Then
  76.  
  77. FileName = "ten_inch"
  78.  
  79. ElseIf PathParsed = "8inch" Then
  80.  
  81. FileName = "eight_inch"
  82.  
  83. End If
  84.  
  85. If FileName <> "" Then
  86.  
  87. PathLeft += Id & "/"
  88.  
  89. Else
  90.  
  91. If PathParsed = "" Then FileName = Id
  92.  
  93. End If
  94.  
  95. End Select
  96.  
  97. If FileName <> "" Then ViewPath = PathLeft & FileName & ".vbhtml"
  98.  
  99.  
  100. If ViewPath = "" Then
  101.  
  102. Return HttpNotFound()
  103.  
  104. Else
  105.  
  106. Return View(ViewPath)
  107.  
  108. End If
  109.  
  110.  
  111. End Function
  112.  
  113.  
  114.  
  115.  
  116. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement