Esempio n. 1
0
        public ActionResult Edit(string ID)
        {
            var model = SysService.GetRole(ID);

            var           rolePages = SysService.GetRolePages(ID);
            RoleAuthModel pagemodel = new RoleAuthModel {
                RoleID = ID, Name = model.Name, Description = model.Description, Pages = new List <AuthPageModel>()
            };

            pagemodel.DataFilter = null;
            pagemodel.Titles     = new List <string>();
            foreach (var g in AppConfig.Current.PageGroups)
            {
                pagemodel.Titles.Add(g.Name);
                foreach (var p in g.Pages.Where(w => w.IsEnable))
                {
                    pagemodel.Pages.Add(new AuthPageModel
                    {
                        PageID  = p.PageID,
                        Title   = p.Title,
                        Name    = g.Name,
                        Actions = p.Config.Actions.Where(a => a.IsEnable).GroupBy(a => a.Title)
                                  .Select(m => new AuthActionModel
                        {
                            ActionTitle = m.Key,
                            ActionValue = m.First().ActionValue,
                            IsSelected  = rolePages.FirstOrDefault(f => f.PageID.Equals(p.PageID) &&
                                                                   (f.ActionValue & m.First().ActionValue) == m.First().ActionValue) != null
                        }).ToList()
                    });
                }
            }
            var companyids = (from rp in rolePages where rp.PageID.Equals("P01001") select rp.DataFilter.ToString()).ToArray();
            var deptids    = (from rp in rolePages where rp.PageID.Equals("P01002") select rp.DataFilter.ToString()).ToArray();;
            var bankids    = (from rp in rolePages where rp.PageID.Equals("P01017") select rp.DataFilter.ToString()).ToArray();

            foreach (var companyid in companyids)
            {
                pagemodel.DataFilter += companyid;
            }
            pagemodel.DataFilter += ":";
            foreach (var deptid in deptids)
            {
                pagemodel.DataFilter += deptid;
            }
            pagemodel.DataFilter += ":";
            foreach (var bankid in bankids)
            {
                pagemodel.DataFilter += bankid;
            }
            return(View(pagemodel));
        }
Esempio n. 2
0
        public ActionResult Detail(string ID)
        {
            var model = SysService.GetRole(ID);

            return(View(model));
        }