Exemplo n.º 1
0
        /// <summary>
        /// Search Work Locations
        /// </summary>
        public IEnumerable <WorkLocation> SearchWorkLocation(WorkLocationSearchRequest request, out int rowCount)
        {
            int fromRow = (request.PageNo - 1) * request.PageSize;
            int toRow   = request.PageSize;

            Expression <Func <WorkLocation, bool> > query =
                workLocation =>
                (string.IsNullOrEmpty(request.WorkLocationFilterText) ||
                 (workLocation.WorkLocationCode.Contains(request.WorkLocationFilterText)) ||
                 (workLocation.WorkLocationName.Contains(request.WorkLocationFilterText))) &&
                (!request.CityId.HasValue || request.CityId == workLocation.Address.CityId) &&
                (!request.AreaId.HasValue || request.AreaId == workLocation.Address.AreaId)
            ;

            rowCount = DbSet.Count(query);
            return(request.IsAsc
                ? DbSet.Include(wl => wl.Phones).Where(query)
                   .OrderBy(workLocationOrderByClause[request.WorkLocationOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList()
                : DbSet.Include(wl => wl.Phones).Where(query)
                   .OrderByDescending(workLocationOrderByClause[request.WorkLocationOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get Work Locations
 /// </summary>
 public WorkLocationSerachRequestResponse Get([FromUri] WorkLocationSearchRequest request)
 {
     if (request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(workLocationService.SearchWorkLocation(request).CreateFrom());
 }
Exemplo n.º 3
0
        /// <summary>
        /// Search Work Locations
        /// </summary>
        public WorkLocationSerachRequestResponse SearchWorkLocation(WorkLocationSearchRequest request)
        {
            int rowCount;

            return(new WorkLocationSerachRequestResponse
            {
                WorkLocations = workLocationRepository.SearchWorkLocation(request, out rowCount),
                TotalCount = rowCount
            });
        }