Enhance ReadByUsernameAsync with new query parameters
Updated IEnvelopeReceiverService to include EnvelopeQuery and ReadReceiverQuery in ReadByUsernameAsync for improved filtering capabilities. Modified EnvelopeReceiverService to implement these changes, allowing for more precise data retrieval. Updated EnvelopeReceiverController to pass the new parameters when calling the service method.
This commit is contained in:
@@ -10,6 +10,8 @@ using Microsoft.Extensions.Logging;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using EnvelopeGenerator.Application.Envelopes;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services;
|
||||
|
||||
@@ -137,9 +139,25 @@ public class EnvelopeReceiverService : BasicCRUDService<IEnvelopeReceiverReposit
|
||||
: Result.Success(code);
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, EnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params int[] ignore_statuses)
|
||||
{
|
||||
var er_list = await _repository.ReadByUsernameAsync(username: username, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses);
|
||||
|
||||
if(envelopeQuery?.Id is int eId)
|
||||
er_list = er_list.Where(er => er.EnvelopeId == eId);
|
||||
|
||||
if (envelopeQuery?.Uuid is string uuid)
|
||||
er_list = er_list.Where(er => er.Envelope?.Uuid == uuid);
|
||||
|
||||
if (envelopeQuery?.Status is int status)
|
||||
er_list = er_list.Where(er => er.Envelope?.Status == status);
|
||||
|
||||
if(receiverQuery?.Id is int id)
|
||||
er_list = er_list.Where(er => er.Receiver?.Id == id);
|
||||
|
||||
if (receiverQuery?.Signature is string signature)
|
||||
er_list = er_list.Where(er => er.Receiver?.Signature == signature);
|
||||
|
||||
var dto_list = _mapper.Map<IEnumerable<EnvelopeReceiverDto>>(er_list);
|
||||
return Result.Success(dto_list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user