public void CreateMenu_Test()
        {
            var menu = new MenuDto
            {
                MenuName = "TestMenu",
                DisplayName = "My test menu",
                Description = "My test menu description",
                Level = MenuLevelDto.Parent,
                Sort = 1,
                CreatedBy = "*****@*****.**"
            };

            using (var service = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
            {
                service.CreateMenu(menu);
            }
        }
 public void ModifyMenu(MenuDto menu)
 {
     var m_menu = this._menuRepository.GetByKey(menu.ID);
     if (m_menu != null)
     {
         m_menu.Update(menu.DisplayName, menu.Description, menu.ParentId, (MenuLevel) menu.Level, menu.Sort,
             menu.ActionsId, menu.UpdatedBy);
         this._menuDomainService.AddOrUpdateMenu(this._menuRepository, m_menu);
     }
 }
        public void CreateMenu(MenuDto menu)
        {
            var m_menu = new Menu(menu.MenuName, menu.DisplayName, menu.Description, menu.ParentId,
                (MenuLevel) menu.Level, menu.Sort, menu.ActionsId, menu.CreatedBy);

            this._menuDomainService.AddOrUpdateMenu(this._menuRepository, m_menu);
        }
        public ActionResult AttachMenuToRole(MenuDto model, Guid[] roles)
        {
            var handler = this.LoginUser.Identity.Name;
            try
            {
                using (var service = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
                {
                    service.AttachMenuToRoles(model.ID, roles, handler);
                }
            }
            catch (Exception)
            {
                return Json(false, "Attach the menu to roles failure.");
            }

            return Json(true);
        }
        public ActionResult AttachMenuToRole(Guid menuId)
        {
            // find all roles.
            // find the roles that include to the menu.
            using (var roleService = ServiceLocator.Instance.Resolve<IRoleService>())
            using (var menuService = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
            {
                var roles = roleService.FindAllRoles();
                var rolesOfMenu = menuService.FindRolesOfMenu(menuId);

                ViewBag.Roles = roles;
                ViewBag.RolesOfMenu = rolesOfMenu;
                var model = new MenuDto {ID = menuId};
                return PartialView(model);
            }
        }
 public ActionResult EditMenu(MenuDto model)
 {
     model.UpdatedBy = this.LoginUser.Identity.Name;
     try
     {
         using (var service = ServiceLocator.Instance.Resolve<IMenuPermissionService>())
         {
             service.ModifyMenu(model);
         }
     }
     catch (Exception)
     {
         return Json(false, "Modify the menu failure.");
     }
     return Json(true);
 }