예제 #1
0
        public bool Delete(int id)
        {
            if (id <= 0)
            {
                return(false);
            }

            Menu menu = _repository.Find(id);

            if (menu == null)
            {
                return(false);
            }

            if (menu.PId == 0)
            {
                List <Menu> tempMenuList = _repository.Select(c => c.PId == menu.Id);

                foreach (var tempMenu in tempMenuList)
                {
                    _repository.Delete(tempMenu);
                    _unitOfWork.Commit();
                }
            }

            List <RoleMenu> roleMenus = _roleMenuService.GetAll(c => c.MenuId == id);

            foreach (var roleMenu in roleMenus)
            {
                _roleMenuService.Delete(roleMenu.Id);
            }

            _repository.Delete(menu);
            return(_unitOfWork.Commit() > 0);
        }
예제 #2
0
        public bool Delete(int id)
        {
            if (id <= 0)
            {
                return(false);
            }

            if (_repository.Find(id) == null)
            {
                return(false);
            }

            List <RoleMenu> roleMenus = _roleMenuService.GetAll(c => c.RoleId == id);

            foreach (var roleMenu in roleMenus)
            {
                _roleMenuService.Delete(roleMenu);
            }

            List <Users> userList = _usersService.GetUsers(c => c.RoleId == id);

            foreach (var users in userList)
            {
                _usersService.Delete(users);
            }

            _repository.Delete(id);
            return(_unitOfWork.Commit() > 0);
        }
예제 #3
0
 public IActionResult GetRoleMenu()
 {
     try
     {
         _roleMenuService.GetAll();
         var menus = _systemMenuService.GetAll();
         return(Ok());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }