/// <summary> /// Get Business Partner Main Types /// </summary> public Models.BpMainTypeSearchRequestResponse Get([FromUri] BpMainTypeSearchRequest request) { if (request == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(bpMainTypeService.SearchBpMainType(request).CreateFrom()); }
/// <summary> /// Search Business Partner Main Type /// </summary> public BpMainTypeSearchRequestResponse SearchBpMainType(BpMainTypeSearchRequest request) { int rowCount; return(new BpMainTypeSearchRequestResponse { BpMainTypes = bpMainTypeRepository.SearchBpMainType(request, out rowCount), TotalCount = rowCount }); }
/// <summary> /// Search Business Partner Main Type /// </summary> public IEnumerable <BusinessPartnerMainType> SearchBpMainType(BpMainTypeSearchRequest request, out int rowCount) { int fromRow = (request.PageNo - 1) * request.PageSize; int toRow = request.PageSize; Expression <Func <BusinessPartnerMainType, bool> > query = city => (string.IsNullOrEmpty(request.BpMainTypeFilterText) || (city.BusinessPartnerMainTypeName.Contains(request.BpMainTypeFilterText)) || (city.BusinessPartnerMainTypeCode.Contains(request.BpMainTypeFilterText))); rowCount = DbSet.Count(query); return(request.IsAsc ? DbSet.Where(query) .OrderBy(bpMainTypeOrderByClause[request.BpMainTypeOrderBy]) .Skip(fromRow) .Take(toRow) .ToList() : DbSet.Where(query) .OrderByDescending(bpMainTypeOrderByClause[request.BpMainTypeOrderBy]) .Skip(fromRow) .Take(toRow) .ToList()); }