diff --git a/EnvelopeGenerator.Application/Contracts/IEnvelopeService.cs b/EnvelopeGenerator.Application/Contracts/IEnvelopeService.cs index ab3d69af..a8cfbab1 100644 --- a/EnvelopeGenerator.Application/Contracts/IEnvelopeService.cs +++ b/EnvelopeGenerator.Application/Contracts/IEnvelopeService.cs @@ -11,6 +11,6 @@ namespace EnvelopeGenerator.Application.Contracts Task> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false); - Task>> ReadByUserAsync(int userId); + Task>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[]ignore_statuses); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/EnvelopeService.cs b/EnvelopeGenerator.Application/Services/EnvelopeService.cs index eed74207..7f76b64e 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeService.cs @@ -33,9 +33,9 @@ namespace EnvelopeGenerator.Application.Services return Result.Success(readDto); } - public async Task>> ReadByUserAsync(int userId) + public async Task>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses) { - var users = await _repository.ReadByUserAsync(userId: userId); + var users = await _repository.ReadByUserAsync(userId: userId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses); var readDto = _mapper.MapOrThrow>(users); return Result.Success(readDto); } diff --git a/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/tables/envelope-table/envelope-table.component.ts b/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/tables/envelope-table/envelope-table.component.ts index eb9ad870..f3a6bf81 100644 --- a/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/tables/envelope-table/envelope-table.component.ts +++ b/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/tables/envelope-table/envelope-table.component.ts @@ -70,6 +70,6 @@ export class EnvelopeTableComponent implements AfterViewInit { private readonly erService: EnvelopeReceiverService = inject(EnvelopeReceiverService); async ngAfterViewInit() { - this.data = await this.eService.getEnvelopeAsync(); + this.data = await this.eService.getEnvelopeAsync(this.options); } } \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/services/envelope.service.ts b/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/services/envelope.service.ts index 903d215e..228f2677 100644 --- a/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/services/envelope.service.ts +++ b/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/services/envelope.service.ts @@ -14,11 +14,20 @@ export class EnvelopeService { this.url = `${api_url}/envelope`; } - public getEnvelope(): Observable { - return this.http.get(this.url); + public getEnvelope(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Observable { + let params = new HttpParams(); + if (options) { + if (options.min_status) + params = params.set('min_status', options.min_status.toString()); + if (options.max_status) + params = params.set('max_status', options.max_status.toString()); + if (options.ignore_status) + params = params.set('ignore_status', options.ignore_status.join(',')); + } + return this.http.get(this.url, { params }); } - public async getEnvelopeAsync(): Promise { - return await firstValueFrom(this.getEnvelope()); + public async getEnvelopeAsync(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Promise { + return await firstValueFrom(this.getEnvelope(options)); } } \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs index 16edc7f3..a7306a36 100644 --- a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs @@ -21,12 +21,15 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers [Authorize] [HttpGet] - public async Task GetCurrentAsync() + public async Task GetCurrentAsync( + [FromQuery] int? min_status = null, + [FromQuery] int? max_status = null, + [FromQuery] params int[] ignore_statuses) { try { if (User.GetId() is int intId) - return await _envelopeService.ReadByUserAsync(intId).ThenAsync( + return await _envelopeService.ReadByUserAsync(intId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses).ThenAsync( Success: Ok, Fail: IActionResult (msg, ntc) => { diff --git a/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeRepository.cs b/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeRepository.cs index 4eaddd94..5b78658e 100644 --- a/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Contracts/IEnvelopeRepository.cs @@ -9,6 +9,6 @@ namespace EnvelopeGenerator.Infrastructure.Contracts Task ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false); - Task> ReadByUserAsync(int userId); + Task> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs b/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs index ae645c2b..d0c09cd0 100644 --- a/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs @@ -46,7 +46,20 @@ namespace EnvelopeGenerator.Infrastructure.Repositories return await query.FirstOrDefaultAsync(); } - public async Task> ReadByUserAsync(int userId) => await _dbSet.AsNoTracking() - .Where(e => e.UserId == userId).ToListAsync(); + public async Task> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses) + { + var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId); + + if (min_status is not null) + query = query.Where(e => e.Status >= min_status); + + if (max_status is not null) + query = query.Where(e => e.Status <= max_status); + + foreach (var ignore_status in ignore_statuses) + query = query.Where(e => e.Status != ignore_status); + + return await query.ToListAsync(); + } } } \ No newline at end of file