Ejemplo n.º 1
0
        public async Task <IActionResult> List(AnagFilters filters)
        {
            var entities = await _anagService.ListAsync(filters : filters);

            var dtos = _mapper.Map(entities, new List <AnagDTO>());

            return(Ok(dtos));
        }
Ejemplo n.º 2
0
        public async Task <IQueryable <Anag_Master> > ListAsync(
            AnagFilters filters,
            SearchStringKindEnum searchStringKind = SearchStringKindEnum.Contains,
            bool includeAddresses         = false,
            bool includeContacts          = false,
            bool includeDocuments         = false,
            bool includeAthletes          = false,
            bool includeAthleteNavigation = false,
            bool includeSports            = false)
        {
            var spec = Spec.Any <Anag_Master>();

            if (filters?.Roles?.Count() > 0)
            {
                spec &= AnagSpecifications.ByRoleIDs(filters.Roles.ToArray());
            }
            if (filters?.CorporateRoles?.Count() > 0)
            {
                spec &= AnagSpecifications.ByCorporateRoleIDs(filters.CorporateRoles.ToArray());
            }
            if (!string.IsNullOrWhiteSpace(filters?.SearchString))
            {
                ASpec <Anag_Master> searchSpec = AnagSpecifications.ByCompleteName(filters.SearchString);
                searchSpec |= AnagSpecifications.ByTaxCode(filters.SearchString);
                searchSpec |= AnagSpecifications.ByVATNo(filters.SearchString);
                spec       &= (searchSpec);
            }

            var query = _repository.GetBySpecification(spec);

            await _repository.Load_DirectNavigation(
                angIds : query.Select(t => t.Ang_ID).ToArray(),
                addresses : includeAddresses,
                contacts : includeContacts,
                documents : includeDocuments,
                athletes : includeAthletes,
                sports : includeSports);

            if (includeAthletes && includeAthleteNavigation)
            {
                await _repository.Load_AthleteNavigation(athIds : query.Where(t => t.Athlete_Master != null).Select(t => t.Athlete_Master.Ath_ID).ToArray());
            }

            return(query);
        }