protected AbstractTicketsLookup WithParameters(TicketLookupParams parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.CreatedAfter.HasValue) { CreatedAfter(parameters.CreatedAfter.Value); } if (parameters.CreatedBefore.HasValue) { CreatedBefore(parameters.CreatedBefore.Value); } if (!string.IsNullOrWhiteSpace(parameters.SearchBy)) { SearchBy(parameters.SearchBy); } if (parameters.TicketIds.Any()) { WithinTicketIds(parameters.TicketIds); } if (parameters.FilterByStatus.HasValue) { FilterByStatus(parameters.FilterByStatus.Value); } if (parameters.FilterBySeverity.HasValue) { FilterBySeverity(parameters.FilterBySeverity.Value); } if (parameters.FilterByPriority.HasValue) { FilterByPriority(parameters.FilterByPriority.Value); } if (parameters.SortBy.HasValue) { SortBy(parameters.SortBy.Value); } return(this); }
public virtual async Task <IList <TicketLookup> > Lookup(TicketLookupParams @params) { WithParameters(@params); var tickets = await _repository.ListAsync(_specification); if (tickets.Any()) { await ExecuteSubQueries(tickets.Select(t => t.TicketId).ToList()); } var details = _mapper.Map <IList <TicketLookup> >(tickets); return(details); }
public virtual async Task <PagedCollection <TicketLookup> > PagedLookup(int page, int pageSize, TicketLookupParams @params) { WithParameters(@params); (page, pageSize) = ValidatePaging(page, pageSize); var pagedCollection = await _repository.PagedListAsync(page, pageSize, _specification, ticket => ticket.TicketId); if (pagedCollection.Items.Any()) { await ExecuteSubQueries(pagedCollection.Items.Select(t => t.TicketId).ToList()); } var details = _mapper.Map <ICollection <TicketLookup> >(pagedCollection.Items); return(new PagedCollection <TicketLookup> ( pagedCollection.Page, pagedCollection.PageSize, pagedCollection.TotalRecords, details )); }