示例#1
0
        public IEnumerable <AgencyViewModel> Get()
        {
            IEnumerable <AgencyViewModel> agencies = agencyRepo.GetAgencies().Select(x => new AgencyViewModel()
            {
                Id       = x.Id,
                Name     = x.Name,
                Email    = x.Email,
                Country  = GetCountryByGovermentId(x.GovermentId),
                IsBranch = x.IsBranch
            });

            return(agencies);
        }
示例#2
0
        public async Task <ActionResult <IEnumerable <AgencyDto> > > GetAgencies(
            [FromQuery] AgenciesParam agenciesParameters)
        {
            if (!_propertyMappingService.ValidMappingExistsFor <AgencyDto, Agency>
                    (agenciesParameters.OrderBy))
            {
                return(BadRequest());
            }

            var agenciesFromRepo = await _AgenciesRepo.GetAgencies(agenciesParameters);

            var previousPageLink = agenciesFromRepo.HasPrevious ?
                                   CreateAgenciesResourceUri(agenciesParameters,
                                                             ResourceUriType.PreviousPage) : null;

            var nextPageLink = agenciesFromRepo.HasNext ?
                               CreateAgenciesResourceUri(agenciesParameters,
                                                         ResourceUriType.NextPage) : null;

            Response.AddPagination(agenciesFromRepo.CurrentPage, agenciesFromRepo.PageSize, agenciesFromRepo.TotalCount,
                                   agenciesFromRepo.TotalPages, previousPageLink, nextPageLink);


            return(Ok(_mapper.Map <IEnumerable <AgencyDto> >(agenciesFromRepo)));
        }
 public List <AgencyModel> GetAgencies()
 {
     return(_agencyRepository.GetAgencies());
 }