コード例 #1
0
 /// <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());
 }
コード例 #2
0
ファイル: BpMainTypeService.cs プロジェクト: VijayMVC/Cares
        /// <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
            });
        }
コード例 #3
0
        /// <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());
        }