예제 #1
0
        public dynamic GetRegion(RegionSearchRequest request)
        {
            RegionSearchSummary regionSearchSummary = new RegionSearchSummary();

            if (CheckClientSecret())
            {
                return(regionSearchSummary.SearchRegions(request));
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
            }
        }
예제 #2
0
        /// <summary>
        /// Search Region
        /// </summary>
        public IEnumerable <Region> SearchRegion(RegionSearchRequest request, out int rowCount)
        {
            int fromRow = (request.PageNo - 1) * request.PageSize;
            int toRow   = request.PageSize;
            Expression <Func <Region, bool> > query =
                region =>
                (string.IsNullOrEmpty(request.RegionFilterText) ||
                 (region.RegionCode.Contains(request.RegionFilterText)) ||
                 (region.RegionName.Contains(request.RegionFilterText))) && (
                    (!request.CountryId.HasValue || request.CountryId == region.CountryId));

            rowCount = DbSet.Count(query);
            return(request.IsAsc
                ? DbSet.Where(query)
                   .OrderBy(regionOrderByClause[request.RegionOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList()
                : DbSet.Where(query)
                   .OrderByDescending(regionOrderByClause[request.RegionOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList());
        }