// GET api controller public HireGroupSearchResponse Get([FromUri] HireGroupSearchRequest request) { if (request == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(hireGroupService.LoadHireGroups((request)).CreateFrom()); }
/// <summary> /// Get All Hire Group based on search crateria /// </summary> public HireGroupSearchResponse GetHireGroups(HireGroupSearchRequest hireGroupSearchRequest) { int fromRow = (hireGroupSearchRequest.PageNo - 1) * hireGroupSearchRequest.PageSize; int toRow = hireGroupSearchRequest.PageSize; Expression <Func <HireGroup, bool> > query = s => (string.IsNullOrEmpty(hireGroupSearchRequest.SearchString) || s.HireGroupCode.Contains(hireGroupSearchRequest.SearchString) || s.HireGroupName.Contains(hireGroupSearchRequest.SearchString)) && (hireGroupSearchRequest.CompanyId == null || s.Company.CompanyId == hireGroupSearchRequest.CompanyId) && (hireGroupSearchRequest.ParentHireGroupId == null || s.ParentHireGroupId == hireGroupSearchRequest.ParentHireGroupId); IEnumerable <HireGroup> hireGroups = hireGroupSearchRequest.IsAsc ? DbSet.Where(query) .OrderBy(hireGroupClause[hireGroupSearchRequest.HireGroupOrderBy]).Skip(fromRow).Take(toRow).ToList() : DbSet.Where(query) .OrderByDescending(hireGroupClause[hireGroupSearchRequest.HireGroupOrderBy]).Skip(fromRow).Take(toRow).ToList(); return(new HireGroupSearchResponse { HireGroups = hireGroups, TotalCount = DbSet.Count(query) }); }
/// <summary> /// Load tariff type, based on search filters /// </summary> /// <param name="hireGroupSearchRequest"></param> /// <returns></returns> public HireGroupSearchResponse LoadHireGroups(HireGroupSearchRequest hireGroupSearchRequest) { return(hireGroupRepository.GetHireGroups(hireGroupSearchRequest)); }