Exemplo n.º 1
0
        public async Task <ActionResult <IEnumerable <Partner> > > GetByName(string name)
        {
            var request = new PartnersSearchRequest
            {
                CompanyName = name
            };

            return(await _partnersService.Search(request).Convert <IEnumerable <Partner> >(this));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Partner> > GetById(int id)
        {
            var request = new PartnersSearchRequest
            {
                Id = id
            };

            return(await _partnersService.Search(request).Convert <Partner>(this));
        }
Exemplo n.º 3
0
        public async Task <IWrappedResponse> Search(PartnersSearchRequest request)
        {
            var query = _olmaPartnerRepo.FindAll()
                        .IgnoreQueryFilters()
                        .AsNoTracking().Where(d => !d.IsDeleted);

            if (request.Id.HasValue)
            {
                var olmaPartner = await query.Where(d => d.Id == request.Id).SingleOrDefaultAsync();

                return(Ok(Mapper.Map <Partner>(olmaPartner)));
            }

            if (!string.IsNullOrEmpty(request.CompanyName))
            {
                var olmaPartner = await query.Where(d => d.CompanyName.Contains(request.CompanyName)).ToListAsync();

                return(Ok(Mapper.Map <IEnumerable <Partner> >(olmaPartner.AsEnumerable())));
            }

            return(Ok(query.ProjectTo <Partner>(Mapper.ConfigurationProvider)));
        }