Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HelpController.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Web.Http;
  3. using System.Web.Mvc;
  4. using WebAPiUtils_test.Areas.HelpPage.Models;
  5. namespace WebAPiUtils_test.Areas.HelpPage.Controllers
  6. {
  7. /// <summary>
  8. /// The controller that will handle requests for the help page.
  9. /// </summary>
  10. public class HelpController : Controller
  11. {
  12. public HelpController()
  13. : this(GlobalConfiguration.Configuration)
  14. {
  15. }
  16. public HelpController(HttpConfiguration config)
  17. {
  18. Configuration = config;
  19. }
  20. public HttpConfiguration Configuration { get; private set; }
  21. public ActionResult Index()
  22. {
  23. ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
  24. return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
  25. }
  26. public ActionResult Api(string apiId)
  27. {
  28. if (!String.IsNullOrEmpty(apiId))
  29. {
  30. HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId);
  31. if (apiModel != null)
  32. {
  33. return View(apiModel);
  34. }
  35. }
  36. return View("Error");
  37. }
  38. }
  39. }