Advertisement
gyrospring

✒ 0007.0016 VS2017 VB MVC5 Razor MachinesController.vb

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