public IActionResult SearchAsync([FromQuery] YachtAttributeSearchModel model) { var result = _yachtAttributeService.SearchAsync(model); if (result.IsSuccessStatusCode) { return(Ok(result)); } return(BadRequest()); }
public IActionResult SearchYachtAttribute([FromQuery] YachtAttributeSearchModel searchModel) { try { var result = _yachtAttributeService.SearchYachtAttributes(searchModel); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.StackTrace.ToString())); } }
public IPagedList<YachtAttributeViewModel> SearchYachtAttributes(YachtAttributeSearchModel searchModel) { var query = _dbYachtContext.YachtAttributes.Where(x => (x.Deleted == null || !x.Deleted.Value) && (string.IsNullOrEmpty(searchModel.AttributeName) || x.AttributeName.Contains(searchModel.AttributeName)) && (searchModel.AttributeCategoryID == null || x.AttributeCategoryFid == searchModel.AttributeCategoryID)).OrderBy(x=>x.AttributeName) .Select(x => new YachtAttributeViewModel { 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<YachtAttributeViewModel>(query, searchModel.PageIndex, searchModel.PageSize); }
public BaseResponse <PagedList <YachtAttributeViewModel> > SearchAsync(YachtAttributeSearchModel searchModel) { var query = (from c in _context.YachtAttributes.AsNoTracking().Where(k => k.Deleted == false && k.AttributeCategoryFid == searchModel.AttributeCategoryFid) select new YachtAttributeViewModel() { Id = c.Id, AttributeCategoryFid = c.AttributeCategoryFid, AttributeName = c.AttributeName, CreatedBy = c.CreatedBy, CreatedDate = c.CreatedDate, IconCssClass = c.IconCssClass, IsDefault = c.IsDefault, LastModifiedBy = c.LastModifiedBy, LastModifiedDate = c.LastModifiedDate, OrderBy = c.OrderBy, Remarks = c.Remarks, ResourceKey = c.ResourceKey, UniqueId = c.UniqueId }); return(BaseResponse <PagedList <YachtAttributeViewModel> > .Success(new PagedList <YachtAttributeViewModel>(query, 1, 10))); }