public async Task <IActionResult> Post([FromBody] CreatePermissionDto command) { await this.SendCommandAsync <CreatePermissionCommand>(new CreatePermissionCommand(command.Name, command.Code)); return(Ok()); }
public void Put(string id, [FromBody] CreatePermissionDto value) { try { PermissionsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _permissionApplicationService.When(value as ICreatePermission); } catch (Exception ex) { var response = PermissionsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }
/// <summary> /// 插入 /// </summary> /// <param name="dto"></param> /// <returns></returns> public PublicResult CreatePermission(CreatePermissionDto dto) { var permission = new Permission { Name = dto.Name, Code = dto.Code, IsActive = dto.IsActive, ParentId = dto.ParentId, OrderIndex = 0, IsSystem = false }; using (var client = DbFactory.CreateClient()) { permission.Id = client.Insertable(permission).ExecuteReturnBigIdentity(); } this.UpdatePathByPermissionId(permission.Id); _distributedCache.Remove(CACHE_ROLE_PERMISSION_ALL_KEY); _distributedCache.Remove(CACHE_PERMISSION_ALL_KEY); _eventPublisher.EntityCreated(permission); return(Ok()); }
public async Task <IActionResult> Post(CreatePermissionDto input) { var permissions = _mapper.Map <Permission>(input); permissions.Created = DateTime.Now; await _permissionRepository.AddAsync(permissions); return(Ok(new Response <Permission>(permissions))); }
public async Task <IActionResult> CreateAsync([FromBody] CreatePermissionDto data) { var result = await _permissionService.CreateAsync(data); if (result == null) { return(NotFound()); } return(Ok(result)); }
/// <summary> /// 保存权限信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <OperateStatus> SavePermission(CreatePermissionDto input) { var operateStatus = new OperateStatus(); try { IList <SystemPermission> systemPermissions = input.Permissiones.Select(per => new SystemPermission { PrivilegeAccess = (byte)input.PrivilegeAccess, PrivilegeAccessValue = per, PrivilegeMasterValue = input.PrivilegeMasterValue, PrivilegeMaster = (byte)input.PrivilegeMaster, PrivilegeMenuId = input.PrivilegeMenuId }).ToList(); //删除该角色的权限信息 await _systemPermissionDapperRepository.DeletePermissionByPrivilegeMasterValue(input.PrivilegeAccess, input.PrivilegeMasterValue, input.PrivilegeMenuId); if (input.PrivilegeMaster == EnumPrivilegeMaster.人员) { //删除对应人员数据 // await _permissionUserRepository.DeletePermissionUser(input.PrivilegeMaster, input.PrivilegeMasterValue); //判断是否具有权限 if (!systemPermissions.Any()) { operateStatus.ResultSign = ResultSign.Successful; operateStatus.Message = Chs.Successful; return(operateStatus); } //插入权限人员数据 var permissionUser = new SystemPermissionUser { PrivilegeMaster = (byte)input.PrivilegeMaster, PrivilegeMasterUserId = input.PrivilegeMasterValue.ToString(), PrivilegeMasterValue = input.PrivilegeMasterValue.ToString() }; // await _permissionUserRepository.Insert(permissionUser); } //是否具有权限数据 if (!systemPermissions.Any()) { operateStatus.ResultSign = ResultSign.Successful; operateStatus.Message = Chs.Successful; return(operateStatus); } // await _systemPermissionDapperRepository.InsertMultiplePetaPocoAsync(systemPermissions); operateStatus.ResultSign = ResultSign.Successful; operateStatus.Message = Chs.Successful; return(operateStatus); } catch { return(operateStatus); } }
public async Task WhenAsync(CreatePermissionDto c) { var idObj = (c as ICreatePermission).PermissionId; var uriParameters = new PermissionUriParameters(); uriParameters.Id = idObj; var req = new PermissionPutRequest(uriParameters, (CreatePermissionDto)c); var resp = await _ramlClient.Permission.Put(req); PermissionProxyUtils.ThrowOnHttpResponseError(resp); }
public async Task <IActionResult> Create([FromBody] CreatePermissionDto creatPermissionDto) { if (!ModelState.IsValid) { return(Failed()); } var identityPermission = mapper.Map <IdentityPermission>(creatPermissionDto); identityPermission.CretaedUser = User.GetUserId(); var result = await _permissionManager.Store.CreateAsync(identityPermission, default); return(Ok(result)); }
// POST: api/Permission create permission public async Task <HandleResult> Post([FromBody] CreatePermissionDto dto) { var command = new CreatePermission( ObjectId.GenerateNewStringId(), dto.AppSystemId, ObjectId.GenerateNewStringId(), dto.Name, dto.PermissionType, dto.IsVisible, dto.ParentPermission, dto.PermissionUrl, dto.Sort, dto.Describe, dto.ReMark); var result = await ExecuteCommandAsync(command); if (result.IsSuccess()) { return(HandleResult.FromSuccess("创建成功", command.Code)); } return(HandleResult.FromFail(result.GetErrorMessage())); }
public void When(CreatePermissionDto c) { WhenAsync(c).GetAwaiter().GetResult(); }
public IActionResult Create(CreatePermissionDto dto) { var result = _permissionService.CreatePermission(dto); return(Json(result)); }