public HttpResponseMessage Search(SearchContactDto searchContactDto)
 {
     try
     {
         var searchResult = this.contactApplicationService.Search(searchContactDto);
         return Request.CreateResponse(HttpStatusCode.OK, searchResult);
     }
     catch (ValidationException ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
     }
 }
Exemplo n.º 2
0
        public IPagedList<ContactDto> Search(SearchContactDto searchContactDto)
        {
            using (var uow = unitOfWorkFactory.GetUnitOfWork())
            {
                var filter = Mapper.Map<SearchContactSpecification>(searchContactDto);
                //ValidateAndThrow(filter);

                return uow
                    .Repository
                    .IsSatisfiedBy(filter)
                    .ProjectTo<ContactDto>()
                    .ApplyPaging(searchContactDto.PageNumber, searchContactDto.PageSize);
            }
        }
Exemplo n.º 3
0
        public IPagedList<ContactDto> Search(SearchContactDto searchContactDto)
        {
            using (var uow = GetUnitOfWork())
            {
                var filter = GetMapper()
                    .Map<SearchContactQuery, SearchContactDto>(searchContactDto);

                var validator = GetValidationFactory().GetValidatorFor<SearchContactQuery>();
                if (validator != null)
                {
                    var validationResult = validator.GetValidationResult(filter);

                    if (validationResult.HasErrors)
                    {
                        throw new ValidationException(validationResult);
                    }
                }

                return uow
                    .Repository
                    .ApplyQuery(filter)
                    .ApplyProjection<ContactDto>()
                    .ApplyPaging(searchContactDto.PageNumber, searchContactDto.PageSize);
            }
        }