/// <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()); }
/// <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()); }
/// <summary> /// Search Work Locations /// </summary> public WorkLocationSerachRequestResponse SearchWorkLocation(WorkLocationSearchRequest request) { int rowCount; return(new WorkLocationSerachRequestResponse { WorkLocations = workLocationRepository.SearchWorkLocation(request, out rowCount), TotalCount = rowCount }); }