Updated IEnvelopeHistoryRepository and IEnvelopeHistoryService interfaces to replace int? status with Constants.EnvelopeStatus? status in CountAsync and ReadAsync methods. Adjusted ReadHistoryQueryHandler and EnvelopeHistoryService methods to accommodate the new type. Modified EnvelopeHistoryRepository to accept Constants.EnvelopeStatus? in relevant methods and marked it as obsolete, suggesting a future refactor.
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using DigitalData.Core.Infrastructure;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using EnvelopeGenerator.Domain;
|
|
|
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
|
|
|
[Obsolete("Use Repository")]
|
|
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
|
|
{
|
|
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeHistories)
|
|
{
|
|
}
|
|
|
|
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
|
|
{
|
|
var query = _dbSet.AsNoTracking();
|
|
|
|
if (envelopeId is not null)
|
|
query = query.Where(eh => eh.EnvelopeId == envelopeId);
|
|
|
|
if (userReference is not null)
|
|
query = query.Where(eh => eh.UserReference == userReference);
|
|
|
|
if (status is not null)
|
|
query = query.Where(eh => eh.Status == status);
|
|
|
|
if (withSender)
|
|
query = query.Include(eh => eh.Sender);
|
|
|
|
if (withReceiver)
|
|
query = query.Include(eh => eh.Receiver);
|
|
|
|
return query;
|
|
}
|
|
|
|
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null) => await By(
|
|
envelopeId: envelopeId,
|
|
userReference: userReference,
|
|
status: status).CountAsync();
|
|
|
|
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
|
|
=> await By(
|
|
envelopeId: envelopeId,
|
|
userReference: userReference,
|
|
status: status,
|
|
withSender: withSender,
|
|
withReceiver: withReceiver).ToListAsync();
|
|
} |