Exemple #1
0
        public List <Menu> GetMenuItems()
        {
            var menus    = _menusService.GetAll();
            var menuInfo = _menuInfoService.GetAll();

            var model = (from m in menus
                         join mI in menuInfo on m.MenuID equals mI.MenuID
                         select new Menu
            {
                Id = m.MenuID,
                Name = mI.Menu,
                ParenetId = m.ParentID
            }
                         ).ToList();

            List <Menu> MenuItmes = new List <Menu>();

            for (int i = 0; i < model.Count; i++)
            {
                var item = new Menu {
                    Id = model[i].Id, Name = model[i].Name, ParenetId = model[i].ParenetId
                };
                MenuItmes.Add(item);
            }
            return(MenuItmes);
        }
Exemple #2
0
        public ActionResult Index(int?menuId = 0, int page = 1)
        {
            try
            {
                var menus    = _menusService.GetAll();
                var menuInfo = _menuInfoService.GetAll();

                var lists    = _listsService.GetAll();
                var listInfo = _listInfoService.GetAll();

                if (menuId > 0)
                {
                    ViewBag.MenuId = menuId;
                }
                else
                {
                    menuId = 0;
                }

                var model = (from m in menus
                             join mI in menuInfo on m.MenuID equals mI.MenuID
                             join l in lists on m.MenuListID equals l.ListID
                             join lI in listInfo on l.ListID equals lI.ListID
                             where m.ParentID == menuId
                             select new MenuListVM
                {
                    MenuID = m.MenuID,
                    MenuInfoID = mI.MenuInfoID,
                    Menu = mI.Menu,
                    MenuListID = m.MenuListID,
                    MenuYeri = lI.Value,
                    Active = m.Active,
                    CreationDate = m.CreationDate
                }
                             ).ToPagedList(page, (int)PagingEnums.Paging.PageSize);

                return(View(model));
            }
            catch (Exception ex)
            {
                TempData.Add("message", "Menü listeleme işleminde hata ile karşılaştı. Hata: " + ex.Message);
                return(View());
            }
        }
Exemple #3
0
        public string ListContentsMenu(string resource, IMenusService menusService, IMenuInfoService menuInfoService)
        {
            string strHtml  = "";
            int    parentID = 0;

            var menus    = menusService.GetAll();
            var menuInfo = menuInfoService.GetAll();

            var model = (from m in menus
                         join mI in menuInfo on m.MenuID equals mI.MenuID
                         where m.ParentID == parentID
                         select new MenuListVM
            {
                MenuID = m.MenuID,
                Menu = mI.Menu
            }
                         ).ToList();

            foreach (var item in model)
            {
                strHtml += "<li>";
                strHtml += string.Format(@"<input id= ""{0}"" type=""checkbox"" />< label for= ""vicepresident""> {1} </label>", item.MenuID, item.Menu);
                strHtml += "</li>";
            }



            //

            //<li>
            //    <input id="profil" type="checkbox" /><label for="vicepresident">Profil</label>
            //    <ul>
            //        <li><input id="hakkimizda" type="checkbox" /><label for="manager4">Hakkımızda</label></li>
            //        <li><input id="degerlerimiz" type="checkbox" /><label for="manager5">Değerlerimiz</label></li>
            //    </ul>
            //</li>



            return(strHtml);
        }
Exemple #4
0
        protected override CoreResponse PageData(CoreRequest core_request)
        {
            var dbcontext = base.Repository.SlaveUnitOfWork.DbContext;
            var query     = dbcontext.UserMenuRole
                            .GroupBy(t => t.UserId).Select(m => new UserMenuRoleDTO
            {
                UserId = m.FirstOrDefault().UserId,
                //UserName = m.FirstOrDefault().UserId,
                Content = string.Join(",", m.Select(x => x.Content.ToString()).Distinct())
            });
            var result = base.PageDataWithQuery(core_request, query);
            List <UserMenuRoleDTO> list = result.DtResponse.data as List <UserMenuRoleDTO>;

            if (list != null && list.Count > 0)
            {
                //List<string> p_list = new List<string>();
                List <string> warehouseUids = new List <string>();

                foreach (var item in list)
                {
                    warehouseUids.AddRange(item.Content.Split(',').ToList());
                }
                warehouseUids = warehouseUids.Distinct().ToList();
                var userPermissions = _menuInfoService.GetAll().Where(w => warehouseUids.Contains(w.Id.ToString())).ToList();
                foreach (var r in list)
                {
                    List <MenuInfoDTO> permissions = new List <MenuInfoDTO>();
                    var warehouseIds = userPermissions.Where(t => r.Content.Split(',').Contains(t.Id.ToString()))
                                       .Select(t => t.Id).Distinct();

                    //父节点
                    foreach (var warehouseId in warehouseIds)
                    {
                        var wares = userPermissions.Where(t => t.Id == warehouseId);
                        var ware  = wares.FirstOrDefault().Clone() as MenuInfoDTO;
                        ware.ContentId = "M#" + ware.TitleId;
                        permissions.Add(ware);
                    }

                    var uids = r.Content.Split(',');
                    //子节点
                    foreach (var wa in uids)
                    {
                        var wares = userPermissions.Where(t => t.Id == Convert.ToInt32(wa));
                        if (wares.Count() > 0)
                        {
                            var ware = wares.FirstOrDefault().Clone() as MenuInfoDTO;
                            ware.ContentId = "D#" + ware.Id;
                            permissions.Add(ware);
                        }
                    }
                    r.Contents = permissions;
                }

                var WarehouseItems = this._menuInfoService.GetAll().Where(w => warehouseUids.Contains(w.Id.ToString())).GroupBy(t => t.TitleId).ToList();
                List <Tuple <string, string> > tuples = new List <Tuple <string, string> >();
                foreach (var p in WarehouseItems)
                {
                    var mx = p.FirstOrDefault();
                    tuples.Add(new Tuple <string, string>("M#" + mx.ContentId, mx.Content));
                    foreach (var q in p)
                    {
                        tuples.Add(new Tuple <string, string>("D#" + q.Id.ToString(), q.ContentId + "-" + q.Content));
                    }
                }
                var users = this._userService.GetAll()
                            .Select(t => new { value = t.Id, label = t.UserName }).Distinct().Future();
                list.ForEach(t =>
                {
                    t.UserName = users.Where(p => p.value.ToString() == t.UserId).Select(p => p.label).FirstOrDefault();
                });
                Dictionary <string, object> options = new Dictionary <string, object>();
                options.Add("UserId", users);
                options.Add("Contents[].ContentId", tuples.Select(s => new { value = s.Item1, label = s.Item2 }));
                result.DtResponse.data    = list;
                result.DtResponse.options = options;
            }
            return(result);
        }