backend: from to

This commit is contained in:
GonnaHetzMe committed 2026-11-22 04:34:07 +01:00
1 parent bbbbca95fa
commit b402d9f92c
3 files changed
+17 -3

No files matched your search

@@ -7,7 +7,8 @@ namespace Helpdesk.Application.Proposals;
public sealed partial class ProposalService
{
public async Task<PagedResult<ProposalSummary>> ListAsync(ProposalQuery filters, CancellationToken ct)
public async Task<PagedResult<ProposalSummary>> ListAsync(
ProposalQuery filters, DateTimeOffset? from, DateTimeOffset? to, CancellationToken ct)
{
await GetActorRoleAsync(ct);
var proposals = db.Proposals.AsNoTracking();
@@ -20,6 +21,12 @@ public sealed partial class ProposalService
proposals = proposals.Where(p => p.CategoryId == categoryId);
if (filters.AuthorId is int authorId)
proposals = proposals.Where(p => p.AuthorId == authorId);
if (from >= to)
throw new BadRequestException("Začátek období musí předcházet jeho konci.");
if (from?.UtcDateTime is DateTime fromUtc)
proposals = proposals.Where(p => p.CreatedAt >= fromUtc);
if (to?.UtcDateTime is DateTime toUtc)
proposals = proposals.Where(p => p.CreatedAt < toUtc);
if (!string.IsNullOrWhiteSpace(filters.Q))
{
var term = filters.Q.Trim();