public IActionResult SearchHotelMerchant([FromQuery] HotelMerchantSearchModel model)
        {
            var response = _hotelMerchantService.SearchHotelMerchant(model);

            if (response != null)
            {
                return(Ok(response));
            }
            return(BadRequest());
        }
示例#2
0
        public IPagedList <HotelMerchantViewModel> SearchHotelMerchant(HotelMerchantSearchModel model)
        {
            var searchString     = !string.IsNullOrEmpty(model.SortString) ? model.SortString : $"{nameof(HotelMerchants.CreatedDate)} Desc";
            var lstHotelMerchant = new PagedList <HotelMerchantViewModel>();
            var query            = _dbHotelContext.HotelMerchants.AsNoTracking().Where(x => x.Deleted == false &&
                                                                                       string.IsNullOrEmpty(model.Country) || x.Country.Contains(model.Country) &&
                                                                                       string.IsNullOrEmpty(model.City) || x.City.Contains(model.City) &&
                                                                                       string.IsNullOrEmpty(model.State) || x.State.Contains(model.State)).Select(x => _mapper.Map <HotelMerchantViewModel>(x)).OrderBy(searchString);

            if (query.Count() > 0)
            {
                lstHotelMerchant = new PagedList <HotelMerchantViewModel>(query, model.PageIndex, model.PageSize);
            }

            return(lstHotelMerchant);
        }