예제 #1
0
        GetRolePermissionDto(int roleId)
        {
            var data  = roleService.Get(roleId);
            var model = new iPow.Infrastructure.Crosscutting.Authorize.Dto.RolePermissionDto();

            model.Id          = data.Id;
            model.RoleID      = data.RoleID;
            model.Description = data.Description;
            var permissionActionIdList = mvcRolePermissionService.GetRolePermissionByRoleId(model.Id).Select(e => e.ActionId);

            var permission = permissionActionIdList.ToList();

            var actionList = mvcActionService.GetList(permissionActionIdList)
                             .Select(e => new iPow.Infrastructure.Crosscutting.Authorize.Dto.MvcActionDto()
            {
                ActionId     = e.Id,
                ActionName   = e.Name,
                ActionRemark = e.Remark,
                ControllerId = e.ControllerId
            });

            var temp = actionList.ToList();

            foreach (var item in temp)
            {
                item.ControllerClassId   = mvcControllerClassService.GetList().Where(d => d.Id == item.ControllerId).Select(d => d.Id).FirstOrDefault();
                item.ControllerClassName = mvcControllerClassService.GetList().Where(d => d.Id == item.ControllerId).Select(d => d.Name).FirstOrDefault();
                item.ControllerName      = mvcControllerService.GetList().Where(d => d.Id == item.ControllerId).Select(d => d.Name).FirstOrDefault();
                item.ControllerRemark    = mvcControllerService.GetList().Where(d => d.Id == item.ControllerId).Select(d => d.Remark).FirstOrDefault();
            }
            model.PermissionList = temp;
            return(model);
        }
예제 #2
0
        public ViewResult Add()
        {
            //做为 DropDownList DataSource
            ViewBag.Actionmodel = mvcControllerService.GetList();
            var model = new Infrastructure.Crosscutting.Authorize.Dto.MvcControllerActionDto();

            return(View(model));
        }
예제 #3
0
 public ViewResult Add(iPow.Infrastructure.Crosscutting.Authorize.Dto.MvcControllerDto MvcController, string State)
 {
     //做为 DropDownList DataSource
     ViewBag.Controllermodel = mvcControllerClassService.GetList();
     if (MvcController != null)
     {
         var mvcclass = mvcControllerClassService.GetClassModelById(MvcController.ClassId);
         //MvcController.ClassName = mvcclass.Name;
         //根据Name查询
         var ControllerByName = mvcControllerService.GetList().Where(e => e.Name == MvcController.Name).FirstOrDefault();
         if (ControllerByName == null)
         {
             //判断Controller 是否存在当前所选Role  若没有则创建 有的话 阻止
             var isexist = mvcControllerService.ClassNameAndControllerNameHasController(MvcController.ClassId, MvcController.Name);
             if (isexist)  //该语法表示 已经存在
             {
                 ModelState.AddModelError("", "该该控制器已经存在同一分类!");
             }
             else
             {
                 iPow.Infrastructure.Data.DataSys.Sys_MvcController addController = new iPow.Infrastructure.Data.DataSys.Sys_MvcController();
                 addController.ClassId          = MvcController.ClassId;
                 addController.Name             = MvcController.Name;
                 addController.AssemblyFullName = addController.Name;
                 addController.Remark           = addController.Name;
                 MvcController.AddTime          = System.DateTime.Now;
                 addController.AddTime          = MvcController.AddTime;
                 addController.IpAddress        = iPow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
                 addController.State            = Convert.ToBoolean(State);
                 addController.SortNum          = MvcController.SortNum;
                 mvcControllerService.Add(addController, null);
                 if (addController.Id > 0)
                 {
                     ModelState.AddModelError("", "恭喜,亲彻底Hold住了");
                 }
                 else
                 {
                     ModelState.AddModelError("", "败笔!亲不给力哦~");
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "添加控制器失败 ");
         }
     }
     else
     {
         ModelState.AddModelError("", "亲请使用楷体字用力填写");
     }
     return(View(MvcController));
 }