The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HelpController.cs 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.Extensions.Logging;
  5. using System.Threading.Tasks;
  6. using Teknik.Areas.Help.ViewModels;
  7. using Teknik.Areas.Users.Models;
  8. using Teknik.Areas.Users.Utility;
  9. using Teknik.Attributes;
  10. using Teknik.Configuration;
  11. using Teknik.Controllers;
  12. using Teknik.Data;
  13. using Teknik.Filters;
  14. using Teknik.Logging;
  15. using Teknik.Utilities;
  16. namespace Teknik.Areas.Help.Controllers
  17. {
  18. [Authorize]
  19. [Area("Help")]
  20. [TrackPageView]
  21. public class HelpController : DefaultController
  22. {
  23. public HelpController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
  24. [AllowAnonymous]
  25. public IActionResult Index()
  26. {
  27. ViewBag.Title = "Help";
  28. HelpViewModel model = new HelpViewModel();
  29. return View(model);
  30. }
  31. [AllowAnonymous]
  32. public IActionResult API(string version, string service)
  33. {
  34. HelpViewModel model = new HelpViewModel();
  35. if (string.IsNullOrEmpty(version) && string.IsNullOrEmpty(service))
  36. {
  37. ViewBag.Title = "API Help";
  38. return View("~/Areas/Help/Views/Help/API/API.cshtml", model);
  39. }
  40. else if(!string.IsNullOrEmpty(version) && !string.IsNullOrEmpty(service))
  41. {
  42. ViewBag.Title = service + " API " + version + " Help";
  43. return View("~/Areas/Help/Views/Help/API/" + version + "/" + service + ".cshtml", model);
  44. }
  45. return new StatusCodeResult(StatusCodes.Status404NotFound);
  46. }
  47. [AllowAnonymous]
  48. public IActionResult Blog()
  49. {
  50. ViewBag.Title = "Blogging Help";
  51. HelpViewModel model = new HelpViewModel();
  52. return View("~/Areas/Help/Views/Help/Blog.cshtml", model);
  53. }
  54. [AllowAnonymous]
  55. public IActionResult Git()
  56. {
  57. ViewBag.Title = "Git Service Help";
  58. HelpViewModel model = new HelpViewModel();
  59. return View("~/Areas/Help/Views/Help/Git.cshtml", model);
  60. }
  61. [AllowAnonymous]
  62. public IActionResult IRC()
  63. {
  64. ViewBag.Title = "IRC Server Help ";
  65. HelpViewModel model = new HelpViewModel();
  66. return View("~/Areas/Help/Views/Help/IRC.cshtml", model);
  67. }
  68. [AllowAnonymous]
  69. public IActionResult Mail()
  70. {
  71. ViewBag.Title = "Mail Server Help";
  72. HelpViewModel model = new HelpViewModel();
  73. return View("~/Areas/Help/Views/Help/Mail.cshtml", model);
  74. }
  75. [AllowAnonymous]
  76. public IActionResult Markdown()
  77. {
  78. ViewBag.Title = "Markdown Help";
  79. HelpViewModel model = new HelpViewModel();
  80. return View("~/Areas/Help/Views/Help/Markdown.cshtml", model);
  81. }
  82. [AllowAnonymous]
  83. public IActionResult Mumble()
  84. {
  85. ViewBag.Title = "Mumble Server Help";
  86. HelpViewModel model = new HelpViewModel();
  87. return View("~/Areas/Help/Views/Help/Mumble.cshtml", model);
  88. }
  89. [AllowAnonymous]
  90. public IActionResult RSS()
  91. {
  92. ViewBag.Title = "RSS Help";
  93. HelpViewModel model = new HelpViewModel();
  94. return View("~/Areas/Help/Views/Help/RSS.cshtml", model);
  95. }
  96. [AllowAnonymous]
  97. public IActionResult Tools()
  98. {
  99. ViewBag.Title = "Tool Help";
  100. HelpViewModel model = new HelpViewModel();
  101. return View("~/Areas/Help/Views/Help/Tools.cshtml", model);
  102. }
  103. [AllowAnonymous]
  104. public async Task<IActionResult> Upload()
  105. {
  106. ViewBag.Title = "Upload Service Help";
  107. UploadHelpViewModel model = new UploadHelpViewModel();
  108. model.MaxUploadSize = _config.UploadConfig.MaxUploadSize;
  109. if (User.Identity.IsAuthenticated)
  110. {
  111. User user = UserHelper.GetUser(_dbContext, User.Identity.Name);
  112. if (user != null)
  113. {
  114. model.MaxUploadSize = _config.UploadConfig.MaxUploadSizeBasic;
  115. IdentityUserInfo userInfo = await IdentityHelper.GetIdentityUserInfo(_config, User.Identity.Name);
  116. if (userInfo.AccountType == AccountType.Premium)
  117. {
  118. model.MaxUploadSize = _config.UploadConfig.MaxUploadSizePremium;
  119. }
  120. }
  121. }
  122. return View("~/Areas/Help/Views/Help/Upload.cshtml", model);
  123. }
  124. }
  125. }