Guest User

Untitled

a guest
May 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public class WebMenu
  2. {
  3.  
  4. public WebMenu()
  5. {
  6. this.Children = new List<WebMenu>();
  7. }
  8.  
  9. [Key]
  10. public int MenuID { get; set; }
  11.  
  12. public string MenuName { get; set; }
  13.  
  14. public int ParentID { get; set; }
  15.  
  16. public string ControllerName { get; set; }
  17.  
  18. public string ActionName { get; set; }
  19.  
  20. public string ExternalLink { get; set; }
  21.  
  22. public List<WebMenu> Children { get; set; }
  23.  
  24. }
  25.  
  26. [Route("content/{id:int}")]
  27. public ActionResult Content()
  28. {
  29. int id = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"]);
  30. TempData["id"] = id;
  31.  
  32.  
  33. return View();
  34. }
  35.  
  36. public ActionResult MenuPartial()
  37. {
  38. dbContext = new DbContext();
  39.  
  40.  
  41. List<WebMenu> Menu = new List<WebMenu>();
  42.  
  43. if (id!=0)
  44. {
  45. int id = (int)TempData["id"];
  46. Menu = dbContext.WebMenu.Where(x => x.MenuID == id).ToList();
  47. //I can get what is clicked.
  48. }
  49.  
  50. WebMenu clickedMenu=Menu.FirstOrDefault();
  51. WebMenu parentMenu=dbContext.WebMenu.Where(x=>x.MenuID==clickedMenu.ParentID).ToList();
  52.  
  53.  
  54. }
Add Comment
Please, Sign In to add comment