public async Task <PaymentReceiptDto[]> GetList(PaymentReceiptFilterDto filter) { _logger.LogDebug($"Calling getList PaymentReceipt"); if (!filter.StartDate.HasValue) { var now = DateTime.UtcNow; filter.StartDate = new DateTime(now.Year, 1, 1); filter.StartDate = Utils.GetDateForStart(filter.StartDate.Value); } if (!filter.EndDate.HasValue) { filter.EndDate = DateTime.MaxValue; filter.EndDate = Utils.GetDateForEnd(filter.EndDate.Value); } IQueryable <PaymentReceipt> query = _dbCtx.PaymentReceipts; if (filter.Id != Guid.Empty) { query = query.Where(x => x.Id == filter.Id); } query = query.Where(x => (x.IssueDate >= filter.StartDate.Value && x.IssueDate <= filter.EndDate.Value)); if (filter.IdCustomer.HasValue && filter.IdCustomer.Value != Guid.Empty) { query = query.Where(x => x.IdCustomer == filter.IdCustomer.Value); } if (filter.WorkableOnly.HasValue && filter.WorkableOnly.Value) { query = query.Where(x => x.InvoiceNumber == null); } var result = await query.OrderByDescending(x => x.PaymentDate.HasValue?x.PaymentDate.Value : DateTime.MaxValue).ThenByDescending(x => x.IssueDate).ToArrayAsync(); return(result.Select(x => x.ToDto()).ToArray()); }
public async Task <ActionResult <PaymentReceiptDto[]> > GetListFiltered([FromBody] PaymentReceiptFilterDto filter) { var res = await _service.GetList(filter); return(res); }