/// <summary> /// 更新某个RoleResource信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <Guid> UpdateRoleResource(RoleResourceDto input) { var role = await _roleResourceRepository.GetAsync(input.Id.GetValueOrDefault()); role.RoleId = input.RoleId; role.TrialCategoryId = input.TrialCategoryId; role.ResourceTypeId = input.ResourceTypeId; role.ResourceGroupId = input.ResourceGroupId; role.Remark = input.Remark; return(role.Id); }
/// <summary> /// 添加RoleResource /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <Guid> AddRoleResource(RoleResourceDto input) { var role = new RoleResource { RoleId = input.RoleId, TrialCategoryId = input.TrialCategoryId, ResourceTypeId = input.ResourceTypeId, ResourceGroupId = input.ResourceGroupId, Remark = input.Remark }; await _roleResourceRepository.InsertAsync(role); return(role.Id); }
/// <summary> /// 获取RoleResources /// </summary> /// <param name="input"></param> /// <returns></returns> public List <RoleResourceDto> GetRoleResources(RoleResourceDto input) { return(_roleResourceRepository .AsNoTracking() .WhereIf(input.Id.HasValue, x => x.Id == input.Id) .WhereIf(input.RoleId.HasValue, x => x.Id == input.RoleId) .WhereIf(input.TrialCategoryId.HasValue, x => x.Id == input.TrialCategoryId) .WhereIf(input.ResourceTypeId.HasValue, x => x.Id == input.ResourceTypeId) .WhereIf(input.ResourceGroupId.HasValue, x => x.Id == input.ResourceGroupId) .OrderBy(p => p.CreationTime) .ProjectTo <RoleResourceDto>(Configuration) .ToList()); }