public async Task <PagedResult <School> > GetPaged(BasePagedRequest request) { var testQueryable = testList.AsQueryable(); var pagedRequest = request.GetPagedRequest(returnResultsOnly: true); var result = await testReFilterActions.GetPaged(testQueryable, pagedRequest); return(result); }
public async Task<PagedResult<StudentViewModel>> GetPagedMappedProjection<U>(BasePagedRequest request) { var testQueryable = testList.AsQueryable(); List<StudentViewModel> mappingFunction(IQueryable<Student> x) => StudentMapper.MapIQueryableToViewModel(x); var pagedRequest = request.GetPagedRequest((Func<IQueryable<Student>, List<StudentViewModel>>)mappingFunction); var result = await testReFilterActions.GetPaged(testQueryable, pagedRequest); return result; }
public async Task <int> MappingTestsFilter(BasePagedRequest request) { var unitUnderTest = new SchoolService(SchoolServiceTestData.Schools); var result = await unitUnderTest.GetPagedMapped <SchoolViewModel>(request); Type type = result.Results.GetType().GetGenericArguments()[0]; Assert.IsTrue(type == typeof(SchoolViewModel)); return(result.RowCount); }
public async Task <PagedResult <SchoolViewModel> > GetPagedSearchQuery <U>(BasePagedRequest request) { var testQueryable = testList.AsQueryable(); List <SchoolViewModel> mappingFunction(List <School> x) => SchoolMapper.MapListToViewModel(x); var pagedRequest = request.GetPagedRequest((Func <List <School>, List <SchoolViewModel> >)mappingFunction); var result = await testReFilterActions.GetBySearchQuery(testQueryable, pagedRequest); return(result); }
public async Task <int> SearchMappingTests(BasePagedRequest request) { var unitUnderTest = new SchoolService(SchoolServiceTestData.Schools); var result = await unitUnderTest.GetPagedSearchQuery <SchoolViewModel>(request); Type type = result.Results.GetType().GetGenericArguments()[0]; Assert.IsTrue(type == typeof(SchoolViewModel)); //Assert.IsTrue(result.Results.TrueForAll(s => s.Name == $"{s.FirstName} {s.LastName}")); return(result.RowCount); }
public async Task <int> MappingTestsProjection(BasePagedRequest request) { var unitUnderTest = new StudentService(StudentServiceTestData.Students); var result = await unitUnderTest.GetPagedMappedProjection <StudentViewModel>(request); Type type = result.Results.GetType().GetGenericArguments()[0]; Assert.IsTrue(type == typeof(StudentViewModel)); Assert.IsTrue(result.Results.TrueForAll(s => s.FullName == $"{s.FirstName} {s.LastName}")); return(result.RowCount); }
public async Task MappingTestsStringSearchInherited() { var request = new BasePagedRequest { PageIndex = 0, PageSize = 10, SearchQuery = "10" }; var unitUnderTest = new SchoolService(SchoolServiceTestData.Schools); var result = await unitUnderTest.GetCollegePagedSearchQuery <CollegeViewModel>(request); Type type = result.Results.GetType().GetGenericArguments()[0]; Assert.IsTrue(type == typeof(CollegeViewModel)); Assert.IsTrue(result.Results.Count == 4); }
public async Task MappingTests_Empty() { var request = new BasePagedRequest { PageIndex = 0, PageSize = 10, SearchQuery = "10" }; var unitUnderTest = new SchoolService(new List <School>()); var result = await unitUnderTest.GetPagedMapped <SchoolViewModel>(request); Type type = result.Results.GetType().GetGenericArguments()[0]; Assert.IsTrue(type == typeof(SchoolViewModel)); Assert.IsTrue(result.Results.Count == 0); //Assert.IsTrue(result.Results.TrueForAll(s => s.Name == $"{s.FirstName} {s.LastName}")); }
public async Task <int> MappingTestsSort(BasePagedRequest request) { var unitUnderTest = new SchoolService(SchoolServiceTestData.Schools); var result = await unitUnderTest.GetPagedMapped <SchoolViewModel>(request); Type type = result.Results.GetType().GetGenericArguments()[0]; Assert.IsTrue(type == typeof(SchoolViewModel)); if (request.PropertyFilterConfigs.Any(pfc => pfc.SortDirection == SortDirection.DESC)) { Assert.IsTrue(result.Results.First().Name.Contains("99")); } else { Assert.IsTrue(result.Results.First().Name.Contains("1")); } return(result.RowCount); }
public async Task <ActionResponse <PagedResult <StudentDto> > > GetAllPaged(BasePagedRequest pagedRequest) { try { List <StudentDto> students = new List <StudentDto>(); var cachedResponse = await cacheService.GetFromCache <List <StudentDto> >(); if (!cachedResponse.IsSuccessAndHasData(out students)) { students = (await GetAll()).GetData(); } var pagedResult = await students.AsQueryable().GetPaged(pagedRequest); return(await ActionResponse <PagedResult <StudentDto> > .ReturnSuccess(pagedResult)); } catch (Exception) { return(await ActionResponse <PagedResult <StudentDto> > .ReturnError("Greška prilikom dohvata straničnih podataka za studente.")); } }
public async Task <ActionResponse <PagedResult <SubjectDto> > > GetAllPaged(BasePagedRequest pagedRequest) { try { var pagedEntityResult = await unitOfWork.GetGenericRepository <Subject>() .GetAllAsQueryable(includeProperties: "Themes").GetPaged(pagedRequest); var pagedResult = new PagedResult <SubjectDto> { CurrentPage = pagedEntityResult.CurrentPage, PageSize = pagedEntityResult.PageSize, PageCount = pagedEntityResult.PageCount, RowCount = pagedEntityResult.RowCount, Results = mapper.Map <List <Subject>, List <SubjectDto> >(pagedEntityResult.Results) }; return(await ActionResponse <PagedResult <SubjectDto> > .ReturnSuccess(pagedResult)); } catch (Exception) { return(await ActionResponse <PagedResult <SubjectDto> > .ReturnError("Greška prilikom dohvata straničnih podataka predmeta.")); } }
public async Task <PagedResult <T> > GetBySearchQuery <T>(IQueryable <T> query, BasePagedRequest pagedRequest, bool applyPagination = false, bool returnQueryOnly = false, bool returnResultsOnly = false) where T : class, new() { Type objectType = query.FirstOrDefault()?.GetType(); if (objectType != null) { var result = new PagedResult <T> { PageIndex = applyPagination ? pagedRequest.PageIndex : default,
public IQueryable <T> ApplyPagination <T>(IQueryable <T> query, BasePagedRequest pagedRequest) where T : class, new() { int skip = pagedRequest.PageIndex * pagedRequest.PageSize; return(query.Skip(skip).Take(pagedRequest.PageSize)); }
public async Task <ActionResponse <PagedResult <ThemeDto> > > GetAllPaged([FromBody] BasePagedRequest pagedRequest) { return(await themeService.GetAllPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <ClassTypeDto> > > GetAllPaged([FromBody] BasePagedRequest pagedRequest) { return(await classTypeService.GetAllClassTypesPaged(pagedRequest)); }
public async Task FilterData(BasePagedRequest request, int count) { }
public async Task <ActionResponse <PagedResult <TeacherViewModel> > > GetAllTeachersPaged([FromBody] BasePagedRequest pagedRequest) { return(await userService.GetAllTeachersPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <EducationProgramDto> > > GetBySearchQuery(BasePagedRequest pagedRequest) { try { List <EducationProgramDto> eduPrograms = new List <EducationProgramDto>(); var cachedResponse = await cacheService.GetFromCache <List <EducationProgramDto> >(); if (!cachedResponse.IsSuccessAndHasData(out eduPrograms)) { eduPrograms = (await GetAll()).GetData(); } var pagedResult = await eduPrograms.AsQueryable().GetBySearchQuery(pagedRequest); return(await ActionResponse <PagedResult <EducationProgramDto> > .ReturnSuccess(pagedResult)); } catch (Exception) { return(await ActionResponse <PagedResult <EducationProgramDto> > .ReturnError("Greška prilikom dohvata straničnih podataka za programe.")); } }
public async Task <ActionResponse <PagedResult <EducationProgramDto> > > GetBySearchQuery([FromBody] BasePagedRequest pagedRequest) { return(await educationProgramService.GetBySearchQuery(pagedRequest)); }
public static async Task <PagedResult <T> > GetBySearchQuery <T>(this IQueryable <T> query, BasePagedRequest pagedRequest) where T : new() { Type objectType = query.FirstOrDefault()?.GetType(); if (objectType != null) { List <PropertyInfo> searchableProperties; if (!string.IsNullOrEmpty(pagedRequest.SearchQuery)) { searchableProperties = objectType .GetProperties() .Where(p => p.GetCustomAttributes().OfType <Searchable>().Any()) .ToList(); if (searchableProperties.Any()) { query = query .Where(q => searchableProperties .Any(p => p.GetValue(q).ToString() .Contains(pagedRequest.SearchQuery, StringComparison.OrdinalIgnoreCase))); } } var result = new PagedResult <T> { RowCount = query.Count() }; result.Results = await Task.FromResult(query.ToList()); return(result); } return(new PagedResult <T> { Results = new List <T>() }); }
public static async Task <PagedResult <T> > GetPaged <T>(this IQueryable <T> query, BasePagedRequest pagedRequest, bool onlyQueryable = false) where T : class, new() { Type objectType = query.FirstOrDefault()?.GetType(); if (objectType != null) { var currentPage = pagedRequest.PageIndex + 1; var result = new PagedResult <T> { CurrentPage = currentPage, PageSize = pagedRequest.PageSize }; //var totalCount = query.Count(); int skip = (currentPage - 1) * pagedRequest.PageSize; if (pagedRequest.Sorting != null && pagedRequest.Sorting.Keys.Count > 0) { query = SortObject(pagedRequest.Sorting, query); } query = query.AsNoTracking(); List <PropertyInfo> searchableProperties; if (!string.IsNullOrEmpty(pagedRequest.SearchQuery)) { searchableProperties = objectType.GetSearchableProperties(); List <string> searchablePropertyNames = new List <string>(); if (searchableProperties.Any()) { searchableProperties.ForEach(sp => { if (sp.DeclaringType.Name != objectType.Name) { searchablePropertyNames.AddRange(objectType.GetPropertiesByTypeNameForValueFetch(sp)); } else { searchablePropertyNames.Add(sp.Name); } }); query = query .Where(q => searchablePropertyNames .Any(p => (q.GetPropValue(p) != null ? q.GetPropValue(p).ToString() : "") .Contains(pagedRequest.SearchQuery, StringComparison.OrdinalIgnoreCase))); } } if (pagedRequest.Where != null && pagedRequest.Where.Properties().Any()) { query = query.FilterObject(pagedRequest.Where); } result.RowCount = query.Count(); result.PageCount = (int)Math.Ceiling((double)result.RowCount / pagedRequest.PageSize); result.ResultQuery = query .Skip(skip) .Take(pagedRequest.PageSize); if (onlyQueryable) { return(result); } result.Results = await Task.FromResult( query .Skip(skip) .Take(pagedRequest.PageSize) .ToList() ); return(result); } return(new PagedResult <T> { Results = new List <T>(), ResultQuery = query }); }
public async Task <ActionResponse <PagedResult <RegionDto> > > GetRegionsByCountryIdPaged([FromBody] BasePagedRequest pagedRequest) { return(await locationService.GetRegionsByCountryIdPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <EducationGroupDto> > > GetAllPaged([FromBody] BasePagedRequest pagedRequest) { return(await educationGroupService.GetAllPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <CityDto> > > GetAllCitiesPaged([FromBody] BasePagedRequest pagedRequest) { return(await locationService.GetAllCitiesPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <BusinessPartnerDto> > > GetAllPaged(BasePagedRequest pagedRequest) { try { var pagedEntityResult = await unitOfWork.GetGenericRepository <BusinessPartner>() .GetAllAsQueryable(bp => bp.IsBusinessPartner, includeProperties: "BusinessPartnerContacts,City,Region,Country").GetPaged(pagedRequest); var pagedResult = new PagedResult <BusinessPartnerDto> { CurrentPage = pagedEntityResult.CurrentPage, PageSize = pagedEntityResult.PageSize, PageCount = pagedEntityResult.PageCount, RowCount = pagedEntityResult.RowCount, Results = mapper.Map <List <BusinessPartner>, List <BusinessPartnerDto> >(pagedEntityResult.Results) }; return(await ActionResponse <PagedResult <BusinessPartnerDto> > .ReturnSuccess(pagedResult)); } catch (Exception) { return(await ActionResponse <PagedResult <BusinessPartnerDto> > .ReturnError("Greška prilikom dohvata straničnih podataka za poslovne partnere.")); } }
public async Task <ActionResponse <PagedResult <MunicipalityDto> > > GetMunicipalitiesByRegionIdPaged([FromBody] BasePagedRequest pagedRequest) { return(await locationService.GetMunicipalitiesByRegionIdPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <EducationLevelDto> > > GetAllPaged(BasePagedRequest pagedRequest) { try { var pagedEntityResult = await unitOfWork.GetGenericRepository <EducationLevel>() .GetAllAsQueryable().GetPaged(pagedRequest); var pagedResult = new PagedResult <EducationLevelDto> { CurrentPage = pagedEntityResult.CurrentPage, PageSize = pagedEntityResult.PageSize, PageCount = pagedEntityResult.PageCount, RowCount = pagedEntityResult.RowCount, Results = mapper.Map <List <EducationLevel>, List <EducationLevelDto> >(pagedEntityResult.Results) }; return(await ActionResponse <PagedResult <EducationLevelDto> > .ReturnSuccess(pagedResult)); } catch (Exception) { return(await ActionResponse <PagedResult <EducationLevelDto> > .ReturnError("Greška prilikom dohvata straničnih podataka razina obrazovanja.")); } }
public async Task <ActionResponse <PagedResult <CountryDto> > > GetCountriesBySearchQuery([FromBody] BasePagedRequest pagedRequest) { return(await locationService.GetCountriesBySearchQuery(pagedRequest)); }
public async Task <ActionResponse <PagedResult <StudentRegisterEntryDto> > > GetAllEntriesByBookIdPaged(BasePagedRequest pagedRequest) { return(await studentRegisterService.GetAllEntriesByBookIdPaged(pagedRequest)); }
public async Task <ActionResponse <PagedResult <StudentDto> > > GetBySearchQuery([FromBody] BasePagedRequest pagedRequest) { return(await studentService.GetBySearchQuery(pagedRequest)); }