Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public class HeaderController : Controller
  2. {
  3. private IMenuService _menuService;
  4.  
  5. public HeaderController(IMenuService menuService)
  6. {
  7. this._menuService = menuService;
  8. }
  9.  
  10. //
  11. // GET: /Header/
  12. public ActionResult Index()
  13. {
  14.  
  15. return View();
  16. }
  17.  
  18.  
  19. public ActionResult GetMenu()
  20. {
  21.  
  22. MenuItem menu = this._menuService.GetMenu();
  23. return View("Menu", menu);
  24.  
  25. }
  26.  
  27. }
  28.  
  29. public class MenuService : IMenuService
  30. {
  31. private IMenuRespository _menuRepository;
  32.  
  33. public MenuService(IMenuRespository menuRepository)
  34. {
  35. this._menuRepository = menuRepository;
  36. }
  37.  
  38. public MenuItem GetMenu()
  39. {
  40. return this._menuRepository.GetMenu();
  41. }
  42. }
  43.  
  44. public class MenuRepository : IMenuRespository
  45. {
  46. public MenuItem GetMenu()
  47. {
  48. //return the menu items
  49. }
  50. }
  51.  
  52. public interface IMenuService
  53. {
  54. MenuItem GetMenu();
  55. }
  56.  
  57. public interface IMenuRespository
  58. {
  59. MenuItem GetMenu();
  60. }
  61.  
  62. MenuItem menu = new MenuService(new MenuRepository());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement