Example #1
0
        public ActionResult CreateRole(SysRoleDto model)
        {
            SysRoleServices sysRoleServices = new SysRoleServices();
            var             result          = sysRoleServices.InertModel(model);

            return(View("RoleIndex"));
        }
Example #2
0
        public bool InertModel(SysRoleDto model)
        {
            model.CreateTime = DateTime.Now;
            model.Id         = Guid.NewGuid();
            var temp = Mapper.Map <SysRoleDto, SysRole>(model);

            return(Respository.Insert(temp) > 0 ? true : false);
        }
Example #3
0
        public async Task OnGetAsync()
        {
            if (!string.IsNullOrEmpty(Id))
            {
                var entity = await _sysRoleService.GetObjectAsync(_ => _.Id == Id);

                SysRoleDto = _sysRoleService.Mapper.Map <SysRoleDto>(entity);
            }
        }
Example #4
0
        /// <summary>
        /// 添加/修改角色
        /// </summary>
        /// <param name="userGroupDto"></param>
        /// <param name="objCheckMenus">角色的菜单权限</param>
        /// <returns></returns>
        public string AddorEditRole(string sjson)
        {
            var model = JsonHelper.JsonToObject <SysRoleVO>(sjson);

            if (model == null)
            {
                return(JsonHelper.ObjectToJson(new ResponseModel
                {
                    StateCode = StatesCode.failure,
                    Messages = "数据解析失败"
                }));
            }
            SysRoleDto        roleDto       = model.roleDto;
            List <SysMenuDto> objCheckMenus = model.objCheckMenus;
            bool   bResult  = true;
            string sMessage = "保存成功";
            var    roleBLL  = injection.GetT <ISysRoleBLL>();
            var    role     = AutoMapper.Mapper.Map <SysRole>(roleDto);

            //添加
            if (string.IsNullOrEmpty(role.RoleId))
            {
                if (roleBLL.GetCount(t => t.RoleName.Equals(role.RoleName) && !t.RoleId.Equals(role.RoleId) && t.DeleteSign.Equals((int)SysEnum.Enum_DeleteSign.Sing_Deleted)) > 0)
                {
                    sMessage = "角色名称不能重复";
                    bResult  = !bResult;
                }
                else
                {
                    role.RoleId       = Guid.NewGuid().ToString();
                    role.DeleteSign   = (Int32)SysEnum.Enum_DeleteSign.Sing_Deleted;
                    role.CreateUserId = injection.GetT <UserAccount>().GetUserInfo().UserId;
                    role.CreateTime   = DateTime.Now;
                    bResult           = roleBLL.Add(role);
                    bResult           = roleBLL.AddRoleMenu(role.RoleId, objCheckMenus).Result;
                }
            }
            else//修改
            {
                var userRole_Edit = roleBLL.GetModels(t => t.RoleId.Equals(role.RoleId)).SingleOrDefault();
                userRole_Edit.RoleName = role.RoleName;
                userRole_Edit.EditTime = DateTime.Now;
                userRole_Edit.Note     = role.Note;
                bResult = roleBLL.Update(userRole_Edit);
                bResult = roleBLL.AddRoleMenu(userRole_Edit.RoleId, objCheckMenus).Result;
            }

            return(JsonHelper.ObjectToJson(new ResponseModel
            {
                StateCode = bResult ? StatesCode.success : StatesCode.failure,
                Messages = sMessage
            }));
        }
Example #5
0
        public async Task SaveRole(SysRoleDto roleDto)
        {
            var role = _mapper.Map <SysRole>(roleDto);

            if (roleDto.ID < 1)
            {
                await _roleRepository.InsertAsync(role);
            }
            else
            {
                await _roleRepository.UpdateAsync(role);
            }
        }
Example #6
0
        public async Task CreateOrUpdateAsync(SysRoleDto dto)
        {
            SysRole sysRole;

            if (String.IsNullOrEmpty(dto.Id))
            {
                sysRole = new SysRole(dto);
            }
            else
            {
                sysRole = await GetObjectAsync(_ => _.Id == dto.Id);

                sysRole.Update(dto);
            }
            await SaveObjectAsync(sysRole);
        }
Example #7
0
        /// <summary>
        /// 添加/修改角色
        /// </summary>
        /// <param name="userGroupDto"></param>
        /// <param name="objCheckMenus">角色的菜单权限</param>
        /// <returns></returns>
        public IActionResult AddorEditRole(SysRoleDto roleDto, List <SysMenuDto> objCheckMenus)
        {
            bool   bResult  = true;
            string sMessage = "保存成功";
            var    role     = AutoMapper.Mapper.Map <SysRole>(roleDto);

            if (_sysRoleBLL.GetCount(t => t.RoleName.Equals(role.RoleName) && !t.RoleId.Equals(role.RoleId) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted)) > 0)
            {
                sMessage = "角色名称不能重复";
                bResult  = !bResult;
            }
            else
            {
                //添加
                if (string.IsNullOrEmpty(role.RoleId))
                {
                    role.DeleteSign   = (Int32)DeleteSign.Sing_Deleted;
                    role.CreateUserId = _userAccount.GetUserInfo().UserId;
                    role.CreateTime   = DateTime.Now;
                    bResult           = _sysRoleBLL.Add(role);
                    bResult           = _sysRoleBLL.AddRoleMenu(role.RoleId, objCheckMenus).Result;
                }
                else//修改
                {
                    var userRole_Edit = _sysRoleBLL.GetModels(t => t.RoleId.Equals(role.RoleId)).SingleOrDefault();
                    userRole_Edit.RoleName = role.RoleName;
                    userRole_Edit.EditTime = DateTime.Now;
                    userRole_Edit.Note     = role.Note;
                    bResult = _sysRoleBLL.Update(userRole_Edit);
                    bResult = _sysRoleBLL.AddRoleMenu(userRole_Edit.RoleId, objCheckMenus).Result;
                }
            }
            return(Ok(new ResponseModel
            {
                RetCode = bResult ? StatesCode.success : StatesCode.failure,
                RetMsg = sMessage
            }));
        }
Example #8
0
        public async Task <IActionResult> OnPostSaveAsync([FromBody] SysRoleDto sysRoleDto)
        {
            await _sysRoleService.CreateOrUpdateAsync(sysRoleDto);

            return(Ok(true));
        }
Example #9
0
 public async Task<ActionResult> SaveRoleData(SysRoleDto[] dtos)
 {
     dtos.CheckNotNull("dtos");
     OperationResult result = await IdentityContract.SaveRoles(dtos);
     return Json(result.ToAjaxResult());
 }
Example #10
0
 public async Task SaveRole(SysRoleDto roleDto)
 {
     await _roleService.SaveRole(roleDto);
 }
Example #11
0
 public async Task SavePermisson(SysRoleDto roleDto)
 {
     await _roleService.SavePermisson(roleDto.ID, roleDto.Permissions);
 }
Example #12
0
 public ApiResult <List <SysRoleDto> > UpdateRole(SysRoleDto sysRoleDto)
 {
     _logger.Info("開始呼叫SysRoleViewService.UpdateRole");
     return(_sysRoleViewService.UpdateRoleView(sysRoleDto));
 }