/// <summary> /// Get Nrt Types /// </summary> public Models.NrtTypeSearchRequestResponse Get([FromUri] NrtTypeSearchRequest oppRequest) { if (oppRequest == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(nrtTypeService.SearchNrtType(oppRequest).CreateFrom()); }
/// <summary> /// Search Nrt Type /// </summary> public NrtTypeSearchRequestResponse SearchNrtType(NrtTypeSearchRequest request) { int rowCount; return(new NrtTypeSearchRequestResponse { NrtTypes = nrtTypeRepository.SearchNrtType(request, out rowCount), TotalCount = rowCount }); }
/// <summary> /// Search Nrt Type /// </summary> public IEnumerable <NrtType> SearchNrtType(NrtTypeSearchRequest request, out int rowCount) { int fromRow = (request.PageNo - 1) * request.PageSize; int toRow = request.PageSize; Expression <Func <NrtType, bool> > query = nrtType => (string.IsNullOrEmpty(request.NrtTypeFilterText) || (nrtType.NrtTypeCode.Contains(request.NrtTypeFilterText)) || (nrtType.NrtTypeName.Contains(request.NrtTypeFilterText))) && ( (!request.VehhicleStatusId.HasValue || request.VehhicleStatusId == nrtType.VehicleStatusId)); rowCount = DbSet.Count(query); return(request.IsAsc ? DbSet.Where(query) .OrderBy(nrtTypeOrderByClause[request.NrtTypeOrderBy]) .Skip(fromRow) .Take(toRow) .ToList() : DbSet.Where(query) .OrderByDescending(nrtTypeOrderByClause[request.NrtTypeOrderBy]) .Skip(fromRow) .Take(toRow) .ToList()); }