Updated references from `Constants` to direct usage of `EnvelopeStatus` and `EmailTemplateType` enums. This change enhances code readability and reduces dependency on the `Constants` class. Modified properties and parameters across command classes, DTOs, repositories, and services to use the enums directly. Updated `ModifyDocStatusCommandBase`, `EnvelopeHistoryDto`, and `ResetEmailTemplateCommand` for improved clarity. Consistent updates across multiple files indicate a systematic refactoring aimed at streamlining the codebase and improving maintainability. Comments and documentation have also been revised to reflect these changes.
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using DigitalData.Core.Infrastructure;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using EnvelopeGenerator.Application.Interfaces.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, 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, EnvelopeStatus? status = null) => await By(
|
|
envelopeId: envelopeId,
|
|
userReference: userReference,
|
|
status: status).CountAsync();
|
|
|
|
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
|
|
=> await By(
|
|
envelopeId: envelopeId,
|
|
userReference: userReference,
|
|
status: status,
|
|
withSender: withSender,
|
|
withReceiver: withReceiver).ToListAsync();
|
|
} |