public BaseResponse <PagedList <HotelInventoryAttributeViewModel> > Search(HotelInventoryAttributeSearchModel searchModel) { try { if (searchModel == null) { return(BaseResponse <PagedList <HotelInventoryAttributeViewModel> > .BadRequest()); } var entity = _db.HotelInventoryAttributes.AsNoTracking().Where(k => k.Deleted == false && k.AttributeCategoryFid == searchModel.AttributeCategoryFid).Select(s => _mapper.Map <HotelInventoryAttributes, HotelInventoryAttributeViewModel>(s)); if (entity.Count() > 0) { return(BaseResponse <PagedList <HotelInventoryAttributeViewModel> > .Success(new PagedList <HotelInventoryAttributeViewModel>(entity, 1, 10))); } return(BaseResponse <PagedList <HotelInventoryAttributeViewModel> > .NoContent(new PagedList <HotelInventoryAttributeViewModel>())); } catch (Exception ex) { return(BaseResponse <PagedList <HotelInventoryAttributeViewModel> > .InternalServerError(ex)); } }
public IActionResult SearchAsync([FromQuery] HotelInventoryAttributeSearchModel model) { var response = _hotelInventoryAttributeService.Search(model); return(Ok(response)); }