public async Task <CustomerProductInstanceDto[]> GetList(CustomerProductInstanceFilterDto filter) { _logger.LogDebug($"Calling getList CustomerProductInstance"); IQueryable <CustomerProductInstance> query = _dbCtx.CustomerProductInstances; if (filter.Id != Guid.Empty) { query = query.Where(x => x.Id == filter.Id); } if (filter.IdCustomer != Guid.Empty) { query = query.Where(x => x.IdCustomer == filter.IdCustomer); } if (filter.IdReceipt == Guid.Empty) { query = query.Where(x => !x.IdReceipt.HasValue); } if (filter.NotExpired.HasValue) { if (filter.NotExpired.Value) { query = query.Where(x => x.PaymentStatus == dal.Entities.PaymentStatus.Completed && (!x.ExpirationDate.HasValue || x.ExpirationDate.Value > DateTime.UtcNow)); } else { query = query.Where(x => x.PaymentStatus == dal.Entities.PaymentStatus.Completed && x.ExpirationDate.HasValue && x.ExpirationDate.Value <= DateTime.UtcNow); } } var result = await query.OrderBy(x => x.Name).ToArrayAsync(); return(result.Select(x => x.ToDto(false)).ToArray()); }
public async Task <ActionResult <CustomerProductInstanceDto[]> > GetListFiltered([FromBody] CustomerProductInstanceFilterDto filter) { var res = await _service.GetList(filter); return(res); }