public IActionResult SearchYachtTourAttribute([FromQuery] YachtTourAttributeSearchModel searchModel) { try { var result = _yachtTourAttributeService.SearchYachtTourAttributes(searchModel); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.StackTrace.ToString())); } }
public IPagedList <YachtTourAttributeViewModel> SearchYachtTourAttributes(YachtTourAttributeSearchModel searchModel) { var query = _dbYachtContext.YachtTourAttributes.Where(x => !x.Deleted && (string.IsNullOrEmpty(searchModel.AttributeName) || x.AttributeName.Contains(searchModel.AttributeName)) && (searchModel.AttributeCategoryID == null || x.AttributeCategoryFid == searchModel.AttributeCategoryID)).OrderByDescending(x => x.OrderBy) .Select(x => new YachtTourAttributeViewModel { Id = x.Id, AttributeCategoryFid = x.AttributeCategoryFid, AttributeName = x.AttributeName, IconCssClass = x.IconCssClass, IsDefault = x.IsDefault, Remarks = x.Remarks, ResourceKey = x.ResourceKey, UniqueId = x.UniqueId, OrderBy = x.OrderBy }); return(new PagedList <YachtTourAttributeViewModel>(query, searchModel.PageIndex, searchModel.PageSize)); }