TekH dc723d9f02 Refactor envelope status handling and imports
Updated `EnvelopeStatus` type in place of `EnvelopeStatusQuery` across multiple files, enhancing the domain model. Added `using` directives for `EnvelopeGenerator.Domain.Constants` in several files, improving clarity and maintainability. Modified import statements in Visual Basic files and repository classes to standardize imports. Overall, these changes aim to refine the structure and clarity of the codebase.
2025-09-01 11:17:27 +02:00

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.Constants;
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();
}