コード例 #1
0
        public void TestFixtureSetUp()
        {
            repository = RepositoryFactory.PrivilegeRepository;

            this.menuRepository = RepositoryFactory.MenuRepository;
            this.roleRepository = RepositoryFactory.RoleRepository;
        }
コード例 #2
0
        public async Task <ActionResult> Delete(long id)
        {
            var json = new JsonModel();
            await SysMenuRepository.DeleteAsync(id);

            json.message = "删除成功!";
            return(Json(json));
        }
コード例 #3
0
ファイル: SysMenuSvc.cs プロジェクト: tomaShaw/StevenDDDSite
        public List <JsTreeJsonModel> GetJsonList(long roleId)
        {
            var menuList = SysMenuRepository.GetJsonList();

            var menuIdList = UserRole2MenuReopsitory.GetLstMenuId(roleId);

            //TODO:jstree
            return(menuList);
        }
コード例 #4
0
        public async Task <List <SysMenuJsonModel> > GetJsonListAsync(long roleId)
        {
            var menuList = await SysMenuRepository.GetJsonList();

            var menuIdList = await UserRole2MenuReopsitory.GetMenuIdListAsync(roleId);

            SetJsonChecked(menuIdList, menuList);

            return(menuList);
        }
コード例 #5
0
        public void TestMethod1()
        {
            IRepositoryContext repositoryContext = new EntityFrameworkRepositoryContext();
            ISysMenuRepository repository = new SysMenuRepository(repositoryContext);
            IList<SysMenu> list = new List<SysMenu>();
            SysMenu menu = new SysMenu();
            menu.ID = new Guid("4AF143A1-29CC-D043-DA49-FAA926ABA470");
            menu.MenuName = "aa";
            list.Add(menu);

            //repository.Remove(list);

            var _list = repository.GetAll(o => o.ID.Equals(menu.ID));
            repository.Remove(_list);
            repository.Context.Commit();
        }
コード例 #6
0
        public async Task <ActionResult> Save(SysMenuModel model)
        {
            var result = new JsonModel();

            if (!ModelState.IsValid)
            {
                result.GetError(ModelState);
                return(Json(result));
            }
            SysMenu menu          = null;
            var     operationType = OperationType.Insert;

            if (model.Id > 0)
            {
                operationType = OperationType.Update;
                menu          = await SysMenuRepository.GetByIdAsync(model.Id);

                if (menu == null)
                {
                    result.statusCode = 300;
                    result.message    = "该条数据不存在,请刷新重试!";
                    return(Json(result));
                }
            }
            else
            {
                menu = new SysMenu();
            }
            menu = Mapper.Map(model, menu);
            if (!string.IsNullOrEmpty(menu.Url))
            {
                menu.Url = menu.Url.Trim().ToLower();
            }
            menu.CommonStatus = CommonStatus.Enabled;
            await SysMenuRepository.SaveAsync(menu);

            await LogRepository.Insert(TableSource.SysMenus, operationType, "", menu.Id);

            menu.IndexOfParent = await SysMenuRepository.GetIndexOfParent(menu);

            result.Data    = menu;
            result.message = "保存成功!";
            return(Json(result));
        }
コード例 #7
0
        public Task <List <SysUserRole2MenuModel> > GetRole2MenuListAsync(long roleId)
        {
            var queryRole2Menu = UserRole2MenuReopsitory.GetQuery(roleId);
            var list           = SysMenuRepository.QueryEnable()
                                 .Where(m => m.Buttons != SysButton.None)
                                 .Join(queryRole2Menu,
                                       menu => menu.Id,
                                       r2m => r2m.MenuId,
                                       (menu, r2m) => new SysUserRole2MenuModel()
            {
                Id              = r2m.Id,
                Buttons         = menu.Buttons,
                MenuId          = menu.Id,
                MenuName        = menu.Name,
                RoleId          = r2m.RoleId,
                SelectedButtons = r2m.Buttons,
                MenuTreePath    = menu.TreePath
            })
                                 .OrderBy(m => m.MenuTreePath)
                                 .ToListAsync();

            return(list);
        }
コード例 #8
0
        public void TestFixtureSetUp()
        {
            repository = RepositoryFactory.PrivilegeRepository;

            this.menuRepository = RepositoryFactory.MenuRepository;
            this.roleRepository = RepositoryFactory.RoleRepository;
        }
コード例 #9
0
        public async Task <ActionResult> Index()
        {
            var data = await SysMenuRepository.GetJsonList();

            return(PartialView("Index", JsonConvert.SerializeObject(data)));
        }
コード例 #10
0
 public SysMenuBLL()
 {
     repository = new SysMenuRepository();
 }
コード例 #11
0
 public SysMenuService()
 {
     _sm = new SysMenuRepository();
 }
コード例 #12
0
        public List <UserMenuModel> GetList(List <long> lstRoleId)
        {
            if (lstRoleId == null || !lstRoleId.Any())
            {
                return(new List <UserMenuModel>());
            }
            var role2MenuQuery = UserRole2MenuReopsitory
                                 .QueryEnable()
                                 .Where(m => lstRoleId.Contains(m.RoleId));
            var menuList = SysMenuRepository.QueryEnable()
                           .Join(role2MenuQuery,
                                 menu => menu.Id,
                                 r2m => r2m.MenuId,
                                 (menu, r2m) => menu)
                           .ToList();
            var r2mList = role2MenuQuery.ToList();
            List <UserMenuModel> list = new List <UserMenuModel>();

            foreach (var role2menu in r2mList)
            {
                var         menuModel   = list.FirstOrDefault(m => m.Id == role2menu.MenuId);
                FilterGroup filterGroup = null;
                if (!string.IsNullOrEmpty(role2menu.FilterGroups))
                {
                    filterGroup = JsonConvert.DeserializeObject <FilterGroup>(role2menu.FilterGroups);
                }
                if (menuModel == null)
                {
                    var menu = menuList.FirstOrDefault(m => m.Id == role2menu.MenuId);
                    if (menu == null)
                    {
                        continue;
                    }
                    menuModel = new UserMenuModel()
                    {
                        Id          = menu.Id,
                        Icon        = menu.Icon,
                        Name        = menu.Name,
                        Pid         = menu.Pid,
                        Sort        = menu.Sort,
                        Source      = menu.Source,
                        Url         = menu.Url,
                        Buttons     = role2menu.Buttons,
                        FilterGroup = filterGroup
                    };
                    list.Add(menuModel);
                    continue;
                }
                menuModel.Buttons = menuModel.Buttons | role2menu.Buttons;
                if (menuModel.FilterGroup == null)
                {
                    menuModel.FilterGroup = filterGroup;
                }
                else if (filterGroup != null)
                {
                    menuModel.FilterGroup = new FilterGroup()
                    {
                        Op        = FilterGroupOp.Or,
                        ListGroup = new List <FilterGroup>()
                        {
                            menuModel.FilterGroup,
                            filterGroup
                        }
                    };
                }
            }
            return(list);
        }