Ejemplo n.º 1
0
        public static (int beginIndex, int endIndex) ConvertPageParametersToIndices(IPagingParameters pagingParameters)
        {
            var beginIndex = (pagingParameters.Page - 1) * pagingParameters.PageSize;
            var endIndex   = beginIndex + pagingParameters.PageSize;

            return(beginIndex, endIndex);
        }
        public virtual IReadItemsByPathRequest DeepCopyGetItemByPathRequest()
        {
            ISessionConfig    connection     = null;
            IItemSource       itemSrc        = null;
            IQueryParameters  payload        = null;
            IPagingParameters pagingSettings = null;

            if (null != this.SessionSettings)
            {
                connection = this.SessionSettings.SessionConfigShallowCopy();
            }

            if (null != this.ItemSource)
            {
                itemSrc = this.ItemSource.ShallowCopy();
            }

            if (null != this.QueryParameters)
            {
                payload = this.QueryParameters.DeepCopy();
            }

            if (null != this.PagingSettings)
            {
                pagingSettings = this.PagingSettings.PagingParametersCopy();
            }


            return(new ReadItemByPathParameters(connection, itemSrc, payload, pagingSettings, this.ItemPath));
        }
        /// <summary>
        /// Gets the paged list of <see cref="IProjectUserPoco"/> models.
        /// </summary>
        /// <param name="pagingParameters">The paging parameters.</param>
        /// <param name="filter">The filter expression.</param>
        /// <param name="orderBy">The order by.</param>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>Paged list of <see cref="IProjectUserPoco"/> models.</returns>
        public virtual IPagedList <IProjectUserPoco> GetPaged(IPagingParameters pagingParameters, Expression <Func <IProjectUserPoco, bool> > filter = null, ISortingParameters orderBy = null, params string[] includeProperties)
        {
            var count    = genericRepository.GetCount();
            var entities = genericRepository.Get(pagingParameters, filter, orderBy, includeProperties);

            return(new StaticPagedList <IProjectUserPoco>(mapper.Map <IEnumerable <IProjectUserPoco> >(entities), pagingParameters.PageNumber, pagingParameters.PageSize, count));
        }
Ejemplo n.º 4
0
        public virtual ISitecoreSearchRequest DeepCopySitecoreSearchRequest()
        {
            ISessionConfig    connection     = null;
            IItemSource       itemSrc        = null;
            IQueryParameters  payload        = null;
            IPagingParameters pagingSettings = null;

            if (null != this.SessionSettings)
            {
                connection = this.SessionSettings.SessionConfigShallowCopy();
            }

            if (null != this.ItemSource)
            {
                itemSrc = this.ItemSource.ShallowCopy();
            }

            if (null != this.QueryParameters)
            {
                payload = this.QueryParameters.DeepCopy();
            }

            if (null != this.PagingSettings)
            {
                pagingSettings = this.PagingSettings.PagingParametersCopy();
            }

            return(new SitecoreSearchParameters(connection, itemSrc, payload, pagingSettings, this.SortParameters, this.IncludeStandardTemplateFields, this.Term));
        }
 protected BaseSpecification(IPagingParameters pagingParameters)
 {
     if (pagingParameters.DisablePaging != true)
     {
         ApplyPaging(pagingParameters.GetSkipValue(), pagingParameters.GetTakeValue());
     }
 }
Ejemplo n.º 6
0
        private async Task <ProjectsViewModel> GetProjectsViewModelAsync(IPagingParameters pagingParameters)
        {
            var sortingParameter = new SortingParameters();

            sortingParameter.Add(new SortingPair(nameof(IProjectPoco.DateCreated), false));

            var statuses   = lookupService.GetAllTaskStatus();
            var domainList = await projectService.GetProjectsPagedAsync(pagingParameters, p => p.CompanyId == this.CompanyId, sortingParameter,
                                                                        this.ToNavPropertyString(nameof(IProjectPoco.Tasks)), this.ToNavPropertyString(nameof(IProjectPoco.ProjectUsers), nameof(IProjectUserPoco.User)));

            var vmProjects = new StaticPagedList <ProjectPreviewViewModel>(Mapper.Map <IEnumerable <ProjectPreviewViewModel> >(domainList.ToList()), pagingParameters.PageNumber, pagingParameters.PageSize, domainList.TotalItemCount);

            foreach (var project in vmProjects)
            {
                var tasks = domainList.First(p => p.Id == project.Id).Tasks;
                var team  = Mapper.Map <IEnumerable <UserPreviewViewModel> >(domainList.First(p => p.Id == project.Id).ProjectUsers.Select(d => d.User));

                project.TaskCount          = tasks.Count();
                project.CompletedTaskCount = tasks.Where(d => d.StatusId == statuses.First(s => s.Abrv == "CLOSED").Id).Count();
                project.LateTaskCount      = tasks.Where(p => p.DueDate <= DateTime.UtcNow).Count();
                project.TeamMembers        = team;
            }

            var vm = new ProjectsViewModel()
            {
                Projects = vmProjects
            };

            return(vm);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Get the list of all <see cref="TEntity"/>.
 /// </summary>
 /// <param name="pagingParameters">The paging parameters.</param>
 /// <param name="orderBy">The order by.</param>
 /// <param name="includeProperties">The include properties.</param>
 /// <returns>List of all <see cref="TEntity"/>.</returns>
 public virtual IEnumerable <TEntity> GetAll(
     IPagingParameters pagingParameters,
     ISortingParameters orderBy = null,
     params string[] includeProperties)
 {
     return(GetQueryable(pagingParameters, null, orderBy, includeProperties).ToList());
 }
        /// <summary>
        /// Gets the paged list of <see cref="IUserPoco"/> models asynchronous.
        /// </summary>
        /// <param name="pagingParameters">The paging parameters.</param>
        /// <param name="filter">The filter expression.</param>
        /// <param name="orderBy">The order by.</param>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>Paged list of <see cref="IUserPoco"/> models asynchronous.</returns>
        public virtual async Task<IPagedList<IUserPoco>> GetPagedAsync(IPagingParameters pagingParameters, Expression<Func<IUserPoco, bool>> filter = null, ISortingParameters orderBy = null, params string[] includeProperties)
        {
            var count = await genericRepository.GetCountAsync(filter);
            var entities = await genericRepository.GetAsync(pagingParameters, filter, orderBy, includeProperties);

            return new StaticPagedList<IUserPoco>(mapper.Map<IEnumerable<IUserPoco>>(entities), pagingParameters.PageNumber, pagingParameters.PageSize, count);
        }
        /// <summary>
        /// Gets a paged list of all <see cref="IUserPoco"/> models.
        /// </summary>
        /// <param name="pagingParameters">The paging parameters.</param>
        /// <param name="orderBy">The order by.</param>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>Paged list of all <see cref="IUserPoco"/> models.</returns>
        public virtual IPagedList<IUserPoco> GetAllPaged(IPagingParameters pagingParameters, ISortingParameters orderBy = null, params string[] includeProperties)
        {
            int count = genericRepository.GetCount();
            var entities = genericRepository.GetAll(pagingParameters, orderBy, includeProperties);

            return new StaticPagedList<IUserPoco>(mapper.Map<IEnumerable<IUserPoco>>(entities), pagingParameters.PageNumber, pagingParameters.PageSize, count);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets the list of all <see cref="TEntity"/> asynchronous.
 /// </summary>
 /// <param name="pagingParameters">The paging parameters.</param>
 /// <param name="orderBy">The order by.</param>
 /// <param name="includeProperties">The include properties.</param>
 /// <returns>List of all <see cref="TEntity"/> asynchronous.</returns>
 public virtual async Task <IEnumerable <TEntity> > GetAllAsync(
     IPagingParameters pagingParameters,
     ISortingParameters orderBy = null,
     params string[] includeProperties)
 {
     return(await GetQueryable(pagingParameters, null, orderBy, includeProperties).ToListAsync());
 }
Ejemplo n.º 11
0
        public void TestReadItemByIdCopiesSessionSettings()
        {
            var defaultSource   = new MutableItemSource("master", "en", 33);
            var sessionSettings = new MutableSessionConfig("localhost", "/sitecore/shell", "v100500");

            ScopeParameters scope = new ScopeParameters();

            scope.AddScope(ScopeType.Parent);
            scope.AddScope(ScopeType.Self);

            string[] fields          = { "Ukraine", "is", "Europe" };
            var      queryParameters = new QueryParameters(PayloadType.Content, scope, fields);

            IPagingParameters       pagingSettings = null;
            ReadItemsByIdParameters request        = new ReadItemsByIdParameters(
                sessionSettings,
                defaultSource,
                queryParameters,
                pagingSettings,
                "{aaaa-aa-bb}");
            var otherRequest = request.DeepCopyGetItemByIdRequest();

            {
                sessionSettings.SetInstanceUrl("paappaa");

                Assert.AreEqual("localhost", otherRequest.SessionSettings.InstanceUrl);
                Assert.AreNotSame(request.SessionSettings, otherRequest.SessionSettings);
                Assert.AreNotSame(request.ItemSource, otherRequest.ItemSource);
                Assert.AreNotSame(request.QueryParameters, otherRequest.QueryParameters);
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Gets the list of <see cref="TEntity"/> asynchronous.
 /// </summary>
 /// <param name="pagingParameters">The paging parameters.</param>
 /// <param name="filter">The filter expression.</param>
 /// <param name="orderBy">The order by.</param>
 /// <param name="includeProperties">The include properties.</param>
 /// <returns>List of <see cref="TEntity"/> asynchronous.</returns>
 public virtual async Task <IEnumerable <TEntity> > GetAsync(
     IPagingParameters pagingParameters,
     Expression <Func <TModel, bool> > filter = null,
     ISortingParameters orderBy = null,
     params string[] includeProperties)
 {
     return(await GetQueryable(pagingParameters, filter, orderBy, includeProperties).ToListAsync());
 }
        /// <summary>
        /// Gets a paged list of all <see cref="IProjectUserPoco"/> models asynchronously.
        /// </summary>
        /// <param name="pagingParameters">The paging parameters.</param>
        /// <param name="orderBy">The order by.</param>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>Paged list of all <see cref="IProjectUserPoco"/> models asynchronously.</returns>
        public virtual async Task <IPagedList <IProjectUserPoco> > GetAllPagedAsync(IPagingParameters pagingParameters, ISortingParameters orderBy = null, params string[] includeProperties)
        {
            int count = await genericRepository.GetCountAsync();

            var entities = await genericRepository.GetAllAsync(pagingParameters, orderBy, includeProperties);

            return(new StaticPagedList <IProjectUserPoco>(mapper.Map <IEnumerable <IProjectUserPoco> >(entities), pagingParameters.PageNumber, pagingParameters.PageSize, count));
        }
Ejemplo n.º 14
0
 public static IPagedList <T> FetchPaged <T>(this IQueryable <T> query, IPagingParameters pagingParameters)
 {
     if (pagingParameters != null)
     {
         return(query.FetchPaged(pagingParameters.PageNumber, pagingParameters.PageSize));
     }
     return(query.FetchPaged(new PagingParameters()));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Asynchronously gets a range of counties, sorted according to the sorting options provided. An optional filter can also be applied.
        /// </summary>
        /// <param name="filter">Instance of type <see cref="IFilter"/>.</param>
        /// <param name="paging">An instance of type <see cref="IPagingParameters"/>, holds paging data.</param>
        /// <param name="sorting">Sorting options</param>
        /// <returns>Returns <see cref="Task{IPagedList{ICounty}}"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="paging"/> is null.</exception>
        public Task<IPagedList<ICounty>> GetAsync(IPagingParameters paging, ISortingParameters sorting, IFilter filter)
        {
            if (paging == null)
            {
                throw new ArgumentNullException("paging");
            }

            return repository.GetAsync(paging, sorting, filter);
        }
        /// <summary>
        /// Gets all or filtered vehicleModels.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns>StaticPagedList if filter != null, if filter == null returns list of all VehicleModel.</returns>
        public virtual async Task<IEnumerable<IVehicleModel>> GetAsync(IPagingParameters pagingParameters, ISortingParameters sortingParameters, IFilter filter)
        {
            var db = ApplicationDbContext.Create();
            var vehicleModels = from s in db.VehicleModels select s;

            string sortExpression = sortingParameters.Sorters.First().GetSortExpression();
            switch (sortExpression)
            {
                case "name_asc":
                    vehicleModels = vehicleModels.OrderBy(s => s.Name);
                    break;
                case "name_dsc":
                    vehicleModels = vehicleModels.OrderByDescending(s => s.Name);
                    break;
                case "abrv_asc":
                    vehicleModels = vehicleModels.OrderBy(s => s.Abrv);
                    break;
                case "abrv_dsc":
                    vehicleModels = vehicleModels.OrderByDescending(s => s.Abrv);
                    break;
                case "vehicleMake_asc":
                    vehicleModels = vehicleModels.OrderBy(s => s.VehicleMake.Name);
                    break;
                case "vehicleMake_dsc":
                    vehicleModels = vehicleModels.OrderByDescending(s => s.VehicleMake.Name);
                    break;
                default :
                    vehicleModels = vehicleModels.OrderBy(s => s.Name);
                    break;
            }

            if (!string.IsNullOrWhiteSpace(filter.SearchString))
            {
                vehicleModels = vehicleModels.Where(s => s.Name.ToUpper()
                .Contains(filter.SearchString.ToUpper())
                    || s.Abrv.ToUpper()
                    .Contains(filter.SearchString.ToUpper())
                    || s.VehicleMake.Name.ToUpper()
                    .Contains(filter.SearchString.ToUpper()));
            }

            if (pagingParameters == null)
            {
                var list = vehicleModels.ToList();
                var mappedList = Mapper.Map<IEnumerable<VehicleModelPoco>>(list);
                return mappedList;
            }

            var paged = await vehicleModels.ToPagedListAsync(pagingParameters.PageNumber, pagingParameters.PageSize);

            var mapped = Mapper.Map<IEnumerable<VehicleModelPoco>>(paged);

            var vehicleModelsPagedList = new StaticPagedList<VehicleModelPoco>(mapped, paged.GetMetaData());

            return vehicleModelsPagedList;
        }
Ejemplo n.º 17
0
        public void TestPagingCanBeOmittedForId()
        {
            IPagingParameters paging = null;
            var request = new ReadItemsByIdParameters(this.sessionConfig, this.defaultSource, null, paging, "{item-id}");

            string result   = this.builderForId.GetUrlForRequest(request);
            string expected = "http://tumba.yumba/-/item/v1?sc_itemid=%7bitem-id%7d";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 18
0
        public void TestPagingCanBeOmittedForQuery()
        {
            IPagingParameters paging = null;
            var request = new ReadItemByQueryParameters(this.sessionConfig, this.defaultSource, null, paging, "/root");

            string result   = this.builderForQuery.GetUrlForRequest(request);
            string expected = "http://tumba.yumba/-/item/v1?query=%2froot";

            Assert.AreEqual(expected, result);
        }
 public ReadItemsByIdParameters(
   ISessionConfig sessionSettings, 
   IItemSource itemSource, 
   IQueryParameters queryParameters, 
   IPagingParameters pagingSettings,
   string itemId)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.ItemId = itemId;
   this.QueryParameters = queryParameters;
   this.PagingSettings = pagingSettings;
 }
Ejemplo n.º 20
0
        public override IReadItemsByIdRequest Build()
        {
            IPagingParameters pagingSettings = this.AccumulatedPagingParameters;

            ReadItemsByIdParameters result = new ReadItemsByIdParameters(
                null,
                this.itemSourceAccumulator,
                this.queryParameters,
                this.icludeStanderdTemplateFields,
                this.itemId);

            return(result);
        }
 public ReadItemByQueryParameters(
   ISessionConfig sessionSettings,
   IItemSource itemSource,
   IQueryParameters queryParameters,
   IPagingParameters pagingSettings,
   string sitecoreQuery)
 {
   this.SessionSettings = sessionSettings;
   this.ItemSource = itemSource;
   this.SitecoreQuery = sitecoreQuery;
   this.QueryParameters = queryParameters;
   this.PagingSettings = pagingSettings;
 }
 public ReadItemByQueryParameters(
     ISessionConfig sessionSettings,
     IItemSource itemSource,
     IQueryParameters queryParameters,
     IPagingParameters pagingSettings,
     string sitecoreQuery)
 {
     this.SessionSettings = sessionSettings;
     this.ItemSource      = itemSource;
     this.SitecoreQuery   = sitecoreQuery;
     this.QueryParameters = queryParameters;
     this.PagingSettings  = pagingSettings;
 }
        private async Task <IPagedList <TaskDTO> > GetTasksListPaged(IPagingParameters pagingParameters, Guid projectId)
        {
            var sortingParameters = new SortingParameters();

            sortingParameters.Add("DateUpdated", false);
            var tasks = await taskService.GetTasksPagedAsync(pagingParameters, p => p.ProjectId == projectId, sortingParameters,
                                                             this.ToNavPropertyString(nameof(ITaskPoco.AssignedToUser)),
                                                             this.ToNavPropertyString(nameof(ITaskPoco.TaskComments)));

            var vm = new StaticPagedList <TaskDTO>(Mapper.Map <IEnumerable <TaskDTO> >(tasks.ToList()), pagingParameters.PageNumber, pagingParameters.PageSize, tasks.TotalItemCount);

            return(vm);
        }
 public ReadItemByPathParameters(
     ISessionConfig sessionSettings,
     IItemSource itemSource,
     IQueryParameters queryParameters,
     IPagingParameters pagingSettings,
     string itemPath)
 {
     this.SessionSettings = sessionSettings;
     this.ItemSource      = itemSource;
     this.ItemPath        = itemPath;
     this.QueryParameters = queryParameters;
     this.PagingSettings  = pagingSettings;
 }
Ejemplo n.º 25
0
        public static IPagingParameters FillPagingParameters(this IPagingParameters destination, IPagingResults parameters)
        {
            if (destination == null)
            {
                destination = new PagingParameters();
            }

            destination.PageNumber = parameters.PageNumber;
            destination.PageSize   = parameters.PageSize;
            destination.TotalItems = parameters.TotalItems;
            destination.TotalPages = parameters.TotalPages;

            return(destination);
        }
        public override IReadItemsByPathRequest Build()
        {
            IPagingParameters pagingSettings  = this.AccumulatedPagingParameters;
            ISessionConfig    sessionSettings = null;

            var result = new ReadItemByPathParameters(
                sessionSettings,
                this.itemSourceAccumulator,
                this.queryParameters,
                pagingSettings,
                this.itemPath);

            return(result);
        }
Ejemplo n.º 27
0
        public IReadItemsByQueryRequest FillReadItemByQueryGaps(IReadItemsByQueryRequest userRequest)
        {
            IItemSource    mergedSource        = this.ItemSourceMerger.FillItemSourceGaps(userRequest.ItemSource);
            ISessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionSettings);

            IPagingParameters pagingSettings = userRequest.PagingSettings;

            return(new ReadItemByQueryParameters(
                       mergedSessionConfig,
                       mergedSource,
                       userRequest.QueryParameters,
                       pagingSettings,
                       userRequest.SitecoreQuery));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Gets the <see cref="TEntity"/> queryable.
        /// </summary>
        /// <param name="pagingParameters">The paging parameters.</param>
        /// <param name="filter">The filter expression.</param>
        /// <param name="orderBy">The order by.</param>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>A query.</returns>
        protected virtual IQueryable <TEntity> GetQueryable(
            IPagingParameters pagingParameters,
            Expression <Func <TModel, bool> > filter = null,
            ISortingParameters orderBy = null,
            params string[] includeProperties)
        {
            // AsNoTracking - disable loading of all navigation properties automatically.
            IQueryable <TEntity> query = context.Set <TEntity>().AsNoTracking();

            // Filtering using Dynamic Linq.
            if (filter != null)
            {
                query = query.Where(DynamicExpressionHandler.GetDynamicQueryString(filter.Body));
            }

            // Include properties.
            if (includeProperties != null && includeProperties.Length > 0)
            {
                foreach (var item in includeProperties)
                {
                    query = query.Include(item);
                }
            }

            // Order by.
            if (orderBy != null && orderBy.Sorters.Count > 0)
            {
                foreach (var item in orderBy.Sorters)
                {
                    if (item.IsAscending)
                    {
                        query = query.OrderBy(item.OrderBy);
                    }
                    else
                    {
                        query = query.OrderBy(item.OrderBy + " descending");
                    }
                }
            }

            // Paging.
            if (pagingParameters != null)
            {
                query = query.Skip(pagingParameters.Skip);
                query = query.Take(pagingParameters.PageSize);
            }

            return(query);
        }
        public override SitecoreSearchParameters Build()
        {
            IPagingParameters pagingSettings = this.AccumulatedPagingParameters;
            //
            SitecoreSearchParameters result = new SitecoreSearchParameters(
                null,
                this.itemSourceAccumulator,
                this.queryParameters,
                pagingSettings,
                null,
                this.icludeStanderdTemplateFields,
                this.sitecoreQuery);

            return(result);
        }
Ejemplo n.º 30
0
        // Gets vehicles.
        // <param name="paging">Paging.</param>
        // <param name="filterVehicle">Filter vehicle.</param>
        // <param name="sorting">Sorting.</param>
        // <returns>Vehicles.</returns>
        public async Task <IEnumerable <IVehicleModel> > GetVehiclesAsync(IPagingParameters paging, IVehicleFilter filterVehicle, ISortingParameters sorting)
        {
            var listOfVehicles = await vehicleContext.VehicleModels.ToListAsync();

            var filteredListOfVehicles = listOfVehicles
                                         .Where(item => String.IsNullOrEmpty(filterVehicle.FindVehicle) ? item != null : item.Name.Contains(filterVehicle.FindVehicle))
                                         .Where(item => filterVehicle.MakeId == Guid.Empty ? item != null : item.VehicleMakeId == filterVehicle.MakeId);

            var sortedList          = filteredListOfVehicles.OrderBy(sorting.SortField + " " + sorting.SortOrder);
            var mappedList          = mapper.Map <List <VehicleModelPoco> >(sortedList);
            var pagedList           = mappedList.ToPagedList(paging.PageNumber, paging.PageSize);
            var pagedListOfVehicles = new StaticPagedList <VehicleModelPoco>(pagedList, pagedList.GetMetaData());

            return(pagedListOfVehicles);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Gets the paged list of <see cref="TEntity" /> asynchronous.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortingParameters">The sorting parameters.</param>
        /// <param name="pagingParameters">The paging parameters.</param>
        /// <param name="includeProperties">The include properties.</param>
        /// <returns>
        /// The paged list of <see cref="!:TEntity" /> paged asynchronous.
        /// </returns>
        public async Task <IPagedCollection <TEntity> > GetPagedAsync(
            Expression <Func <TEntity, bool> > filter = null,
            ISortingParameters sortingParameters      = null,
            IPagingParameters pagingParameters        = null,
            params string[] includeProperties)
        {
            _logger.LogDebug("{Method}, {SortingParameters}, {PagingParameters}, {IncludeProperties}", nameof(Repository <TEntity> .GetPagedAsync), sortingParameters, pagingParameters, includeProperties);

            // NOTE: EF Core does not support multiple parallel operations being run on the same context instance.
            var totalCount = await GetCountAsync();

            var result = await GetQueryable(filter, sortingParameters, pagingParameters, includeProperties).ToListAsync();

            return(new PagedCollection <TEntity>(result, totalCount, pagingParameters.PageNumber, pagingParameters.PageSize));
        }
        public ISitecoreSearchRequest FillSitecoreSearchGaps(ISitecoreSearchRequest userRequest)
        {
            IItemSource    mergedSource        = this.ItemSourceMerger.FillItemSourceGaps(userRequest.ItemSource);
            ISessionConfig mergedSessionConfig = this.SessionConfigMerger.FillSessionConfigGaps(userRequest.SessionSettings);

            IPagingParameters pagingSettings = userRequest.PagingSettings;

            return(new SitecoreSearchParameters(
                       mergedSessionConfig,
                       mergedSource,
                       userRequest.QueryParameters,
                       pagingSettings,
                       userRequest.SortParameters,
                       userRequest.IncludeStandardTemplateFields,
                       userRequest.Term));
        }
Ejemplo n.º 33
0
        public override ISitecoreStoredSearchRequest Build()
        {
            IPagingParameters pagingSettings = this.AccumulatedPagingParameters;

            StoredSearchParameters result = new StoredSearchParameters(
                null,
                this.itemSourceAccumulator,
                this.queryParameters,
                this.AccumulatedPagingParameters,
                this.itemId,
                this.icludeStanderdTemplateFields,
                null);


            return(result);
        }
Ejemplo n.º 34
0
        private string CreateMatchUrl(string accountId, IPagingParameters parameters, ResourceUriType uriType)
        {
            var paramsObject = new
            {
                accountId,
                pageSize = parameters.PageSize,
                page     = uriType switch
                {
                    ResourceUriType.PrevPage => parameters.Page - 1,
                    ResourceUriType.NextPage => parameters.Page + 1,
                    _ => parameters.Page
                }
            };

            return(Url.Link("GetMatchesByAccount", paramsObject));
        }
    public string BuildUrlQueryString(IPagingParameters pagingParameters)
    {
      if (null == pagingParameters)
      {
        return null;
      }
        
      var invariangCulture = CultureInfo.InvariantCulture;
      string strPerPage = pagingParameters.ItemsPerPageCount.ToString(invariangCulture);
      string strPageNumber = pagingParameters.PageNumber.ToString(invariangCulture);

      string result = 
        this.webApiGrammar.PageNumberParameterName + this.restGrammar.KeyValuePairSeparator + strPageNumber +
        this.restGrammar.FieldSeparator +
        this.webApiGrammar.ItemsPerPageParameterName + this.restGrammar.KeyValuePairSeparator + strPerPage;

      return result;
    }
 /// <summary>
 /// Asynchronously gets a range of locations.
 /// </summary>
 /// <param name="paging">A class instance that implements <see cref="IPagingParameters"/>, holds paging data.</param>
 /// <returns>Returns <see cref="Task{IPagedList{ILocation}}"/></returns>
 public static Task<IPagedList<ILocation>> GetAsync(this ILocationService locationService, IPagingParameters paging)
 {
     return locationService.GetAsync(paging, null, null);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Gets all or filtered vehicleMakes.
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public virtual async Task<IEnumerable<IVehicleMake>> GetAsync(IPagingParameters pagingParameters, ISortingParameters sortingParameters, IFilter filter)
 {
     return await Repository.GetAsync(pagingParameters, sortingParameters, filter);
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Asynchronously gets a range of locations which names contain the string given by the filter object.
        /// </summary>
        /// <param name="filter">Filter instance of type <see cref="IFilter"/></param>
        /// <param name="paging">A class instance that implements <see cref="IPagingParameters"/>, holds paging data.</param>
        /// <returns>Returns <see cref="Task{IPagedList{ILocation}}"/></returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="paging"/> is null.</exception>
        public async Task<IPagedList<ILocation>> GetAsync(IPagingParameters paging, ISortingParameters sorting, IFilter filter)
        {
            if (paging == null)
            {
                throw new ArgumentNullException("paging");
            }

            if (sorting == null)
            {
                IList<ISortingPair> sortPair = new List<ISortingPair>()
                {
                    new SortingPair("Name")
                };
                sorting = new SortingParameters(sortPair);
            }

            var query = repository.GetAll<LocationEntity>()
                            .OrderBy(sorting.GetJoinedSortExpressions());

            if(filter != null && !string.IsNullOrEmpty(filter.SearchString))
            {
                query = query.Where(e => e.Name.ToLower().Contains(filter.SearchString.ToLower()));
            }

            return Mapper.Map<IPagedList<ILocation>>(await query.ToPagedListAsync(paging.PageNumber, paging.PageSize));
        }
 /// <summary>
 /// Asynchronously gets a list of locations.
 /// </summary>
 /// <param name="paging">An instance of <see cref="IPagingParameters"/>, provides paging options.</param>
 /// <returns>Returns <see cref="Task{IEnumerable{ILocation}}"/></returns>
 public static Task<IPagedList<ILocation>> GetAsync(this ILocationRepository repository, IPagingParameters paging)
 {
     return repository.GetAsync(paging, null, null);
 }