Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HeaderController : Controller
- {
- private IMenuService _menuService;
- public HeaderController(IMenuService menuService)
- {
- this._menuService = menuService;
- }
- //
- // GET: /Header/
- public ActionResult Index()
- {
- return View();
- }
- public ActionResult GetMenu()
- {
- MenuItem menu = this._menuService.GetMenu();
- return View("Menu", menu);
- }
- }
- public class MenuService : IMenuService
- {
- private IMenuRespository _menuRepository;
- public MenuService(IMenuRespository menuRepository)
- {
- this._menuRepository = menuRepository;
- }
- public MenuItem GetMenu()
- {
- return this._menuRepository.GetMenu();
- }
- }
- public class MenuRepository : IMenuRespository
- {
- public MenuItem GetMenu()
- {
- //return the menu items
- }
- }
- public interface IMenuService
- {
- MenuItem GetMenu();
- }
- public interface IMenuRespository
- {
- MenuItem GetMenu();
- }
- MenuItem menu = new MenuService(new MenuRepository());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement