Esempio n. 1
0
        public IEnumerable <WebMenuDTO> GetWebMenuTreeList()
        {
            List <WebMenuDTO> result = new List <WebMenuDTO>();

            SessionManager.DoWork(session =>
            {
                Guid root = Guid.Empty;
                List <WebMenu> parentList = new List <WebMenu>();
                List <WebMenu> childList  = new List <WebMenu>();
                parentList = session.Query <WebMenu>().Where(w => w.ParentMenu.Id == root).OrderBy(w => w.Index).ToList();
                foreach (WebMenu pl in parentList)
                {
                    WebMenuDTO pd = pl.Map <WebMenuDTO>();
                    pd.ParentId   = null;
                    result.Add(pd);
                }
                childList = session.Query <WebMenu>().Where(w => w.ParentMenu.Id != root && w.ParentMenu.Id != null).OrderBy(w => w.Index).ToList();
                foreach (WebMenu cl in childList)
                {
                    WebMenu temp = session.Query <WebMenu>().Where(w => w.Id == cl.ParentMenu.Id).SingleOrDefault();
                    if (temp.ParentMenu.Id == root)
                    {
                        WebMenuDTO cd = cl.Map <WebMenuDTO>();
                        cd.ParentId   = cl.ParentMenu.Id;
                        result.Add(cd);
                    }
                }
            });
            return(result);
        }
Esempio n. 2
0
        public IEnumerable <WebMenuHierarchyDTO> GetWebMenuHierarchy(Guid webGroupId)
        {
            List <WebMenuHierarchyDTO> result = new List <WebMenuHierarchyDTO>();

            SessionManager.DoWork(session =>
            {
                List <Guid> webMenuIds = new List <Guid>();
                WebGroup g             = session.Query <WebGroup>().SingleOrDefault(p => p.Id == webGroupId);
                if (g != null)
                {
                    webMenuIds = g.WebMenus.Select(d => d.Id).ToList();
                }

                Guid root = Guid.Empty;
                List <WebMenu> parentList = new List <WebMenu>();
                parentList = session.Query <WebMenu>().Where(w => w.ParentMenu.Id == root).OrderBy(w => w.Index).ToList();
                foreach (WebMenu p in parentList)
                {
                    WebMenuHierarchyDTO pd = new WebMenuHierarchyDTO();
                    pd.Id   = p.Id;
                    pd.Name = p.Name;
                    result.Add(pd);
                }
                List <WebMenu> childList       = new List <WebMenu>();
                List <WebMenuDTO> childListDTO = new List <WebMenuDTO>();
                childList = session.Query <WebMenu>().Where(w => w.ParentMenu.Id != root).OrderBy(w => w.Index).ToList();
                foreach (WebMenu cl in childList)
                {
                    WebMenu temp = session.Query <WebMenu>().Where(w => w.Id == cl.ParentMenu.Id).SingleOrDefault();
                    if (temp.ParentMenu.Id == root)
                    {
                        WebMenuDTO cd = new WebMenuDTO();
                        cd.Id         = cl.Id;
                        cd.Name       = cl.Name;
                        cd.ParentId   = cl.ParentMenu.Id;
                        childListDTO.Add(cd);
                    }
                }
                foreach (WebMenuHierarchyDTO dh in result)
                {
                    dh.items = new List <WebMenuDTO>();
                    foreach (WebMenuDTO dt in childListDTO)
                    {
                        if (dt.ParentId == dh.Id)
                        {
                            if (webMenuIds.Contains(dt.Id))
                            {
                                dt.@checked = true;
                            }
                            dh.items.Add(dt);
                        }
                    }
                    if (webMenuIds.Contains(dh.Id) && (dh.items.Count < 1))
                    {
                        dh.@checked = true;
                    }
                }
            });
            return(result);
        }
Esempio n. 3
0
        public WebMenuDTO GetObject(Guid id)
        {
            WebMenuDTO result = new WebMenuDTO();

            SessionManager.DoWork(session =>
            {
                WebMenu webmenu = session.Query <WebMenu>().Where(w => w.Id == id).SingleOrDefault();
                result.Id       = webmenu.Id;
                result.Name     = webmenu.Name;
                result.Index    = webmenu.Index;
                result.ParentId = webmenu.ParentMenu != null ? webmenu.ParentMenu.Id : Guid.Empty;
            });
            return(result);
        }
Esempio n. 4
0
        public async Task <ResultModel <WebMenuDTO> > GetWebMenuInfo([Required(ErrorMessage = "唯一标识不可以为空")] Guid id)
        {
            try
            {
                WebMenuDTO result = await _webMenuService.GetWebMenuInfoAsync(id);

                return(ResultModel <WebMenuDTO> .Success(result, "查询成功"));
            }
            catch (AspectInvocationException ex)
            {
                return(ResultModel <WebMenuDTO> .Fail(ex.InnerException?.Message));
            }
            catch (InvalidOperationException ex)
            {
                return(ResultModel <WebMenuDTO> .Fail(ex.Message));
            }
        }
Esempio n. 5
0
        public IEnumerable <WebMenuDTO> GetListParentMenu()
        {
            List <WebMenuDTO> result = new List <WebMenuDTO>();

            SessionManager.DoWork(session =>
            {
                Guid root = Guid.Empty;
                List <WebMenu> parentList = new List <WebMenu>();
                parentList = session.Query <WebMenu>().Where(w => w.ParentMenu.Id == root).OrderBy(w => w.Index).ToList();
                foreach (WebMenu pl in parentList)
                {
                    WebMenuDTO pd = pl.Map <WebMenuDTO>();
                    pd.ParentId   = null;
                    result.Add(pd);
                }
            });
            return(result);
        }
Esempio n. 6
0
        public int Put(WebMenuDTO obj)
        {
            int result = 0;

            SessionManager.DoWork(session =>
            {
                WebMenu web = session.Query <WebMenu>().Where(w => w.Id == obj.Id).SingleOrDefault();
                web.Name    = obj.Name;
                web.Index   = obj.Index;
                if (web.ParentMenu.Id != obj.ParentId)
                {
                    WebMenu parent = session.Query <WebMenu>().Where(w => w.Id == obj.ParentId).SingleOrDefault();
                    web.ParentMenu = parent;
                }
                session.SaveOrUpdate(web);
                result = 1;
            });
            return(result);
        }