/// <summary> /// Get Designations /// </summary> public DesignationSearchRequestResponse Get([FromUri] DesignationSearchRequest request) { if (request == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(designationService.SearchDesignation(request).CreateFrom()); }
/// <summary> /// Search Designation /// </summary> public DesignationSearchRequestResponse SearchDesignation(DesignationSearchRequest request) { int rowCount; return(new DesignationSearchRequestResponse { Designations = designationRepository.SearchDesignation(request, out rowCount), TotalCount = rowCount }); }
/// <summary> /// Search Designation /// </summary> public IEnumerable <Designation> SearchDesignation(DesignationSearchRequest request, out int rowCount) { int fromRow = (request.PageNo - 1) * request.PageSize; int toRow = request.PageSize; Expression <Func <Designation, bool> > query = designation => (string.IsNullOrEmpty(request.DesignationFilterText) || (designation.DesignationCode.Contains(request.DesignationFilterText)) || (designation.DesignationName.Contains(request.DesignationFilterText))); rowCount = DbSet.Count(query); return(request.IsAsc ? DbSet.Where(query) .OrderBy(designationOrderByClause[request.DesignationOrderBy]) .Skip(fromRow) .Take(toRow) .ToList() : DbSet.Where(query) .OrderByDescending(designationOrderByClause[request.DesignationOrderBy]) .Skip(fromRow) .Take(toRow) .ToList()); }