public void AddingItemWithParamShouldAddToList() { // Arrange var sortingInfo = new SortingInfo(); var arguments = new Dictionary <string, object> { { "sort", sortingInfo } }; _actionExecutingContext = new ActionExecutingContext(_actionContext, new List <IFilterMetadata>(), arguments, null); // Act _sortingFilter.OnActionExecuting(_actionExecutingContext); // Assert Assert.Null(_actionExecutingContext.Result); Assert.Equal(2, sortingInfo.Size()); Assert.Collection(sortingInfo.Iterator(), element => { Assert.Equal("prop1", element.GetOrderBy()); Assert.True(element.IsAsc()); }, element => { Assert.Equal("prop2", element.GetOrderBy()); Assert.False(element.IsAsc()); } ); }
public IActionResult Get([FromQuery] PaginationParams paginationParams, [FromQuery] SortingInfo sortingInfo) { var companies = Service.GetList(paginationParams, sortingInfo); return(Ok(companies)); }
public LibraryTypeQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("Title", SortOrder.Descending); Paging = new PagerInfo(1, 20); SetQ(Properties.Title).SetIsLocalized(true); }
public BaseSortingAlgorithm(SortingInfo sortingInfo, NoisyCounter counter, ChartValues <int> dataset) { this.SortingInfo = sortingInfo; this.Counter = counter; this.Dataset = dataset; this.AlgorithmStatus = TaskStatus.WaitingForActivation; this.PopulateTitle(); }
public RoleQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo(Properties.RoleName, SortOrder.Descending); Paging = new PagerInfo(1, Settings.General.PageSize); AddProperty(Properties.RoleName).SetIsLocalized(false).SetOperator(QueryOperator.StartsWith).SetList(); }
public void ParseSortingHeaderWithInValidString() { // Actual var error = Assert.Throws(typeof(InvalidOperationException), () => SortingInfo.Parse("anand_sort")); // Assertions Assert.Equal("Sorting Header mal formed for sorting", error.Message); }
public void ResultNullOnParsingEmptyHeader() { // Actual var sortingInfo = SortingInfo.Parse(null); // Assertions Assert.Null(sortingInfo); }
public ClassificationQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("Name", SortOrder.Descending); Sorting = new SortingInfo("Alias", SortOrder.Descending); Paging = new PagerInfo(1, 20); AddProperty(Properties.ClassificationType); }
public override List <Company> GetList(PaginationParams paginationParams, SortingInfo sortingInfo) { sortingInfo.Add(nameof(Company.CompanyName), Sorting.Sorting.Asc); var query = Context.Companies.GetList(paginationParams).IncludeOrderBy(sortingInfo).Include(a => a.Address) .AsNoTracking(); return(query.ToList()); }
public KartaQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("Title", SortOrder.Descending); SetQ(Properties.Title).SetIsLocalized(true); SetQ(Properties.Summary).SetIsLocalized(true); AddProperty(Properties.Category); Paging = new PagerInfo(1, 20); }
public LabelQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("Ordinal", SortOrder.Ascending); Paging = new PagerInfo(1, 50); AddProperty(Properties.Classification); GetProperty(Properties.Name).SetOperator(QueryOperator.StartsWith); }
/// <summary> /// Provide current sorting info. /// </summary> /// <param name="info">Current sorting information.</param> /// <returns>Instance of ISortingControlBuilder.</returns> public ISortingControlBuilder <TModel> WithSortingInfo(SortingInfo info) { if (info == null) { throw new ArgumentNullException(nameof(info)); } Info = info; return(this); }
private static Expression <Func <TEntity, T> > CheckSorting <T>(SortingInfo sortingInfo, Expression <Func <TEntity, T> > x) { if (x == null) { sortingInfo.IsValid = false; sortingInfo.Reason = string.Format("Incorrect sorting field {0}", sortingInfo.Property); return(null); } return(x); }
public EventQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("CreatedOn", SortOrder.Descending); Paging = new PagerInfo(1, 20); SetQ(Properties.Title).SetIsLocalized(true); AddProperty(Properties.StartsOn).SetOperator(QueryOperator.Between); AddProperty(Properties.EndsOn).SetOperator(QueryOperator.Between); AddProperty(Properties.Location); }
public ArticleQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("CreatedOn", SortOrder.Descending); Paging = new PagerInfo(1, Settings.General.PageSize); //Paging = new PagerInfo(1, Settings.General.PageSize); SetQ(Properties.Title).SetIsLocalized(true); SetQ(Properties.Summary).SetIsLocalized(true); SetQ(Properties.Content).SetIsLocalized(true); AddProperty(Properties.Category); }
public Sorting ToDomainObject(SortingInfo sortingInfo) { var sorting = new Sorting(); if (sortingInfo != null) { sorting.SortBy = sortingInfo.SortBy.ToString(); sorting.SortDirection = sortingInfo.SortDirection.ToString().ToLower(); } return(sorting); }
public DocumentQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo("Ordinal", SortOrder.Ascending); Paging = new PagerInfo(1, Settings.General.PageSize); SetQ(Properties.Title).SetIsLocalized(true); AddProperty(Properties.Extension); AddProperty(Properties.FileName).SetOperator(QueryOperator.StartsWith); AddProperty(Properties.Category); }
public void ParseSortingHeaderWithValidString() { // Actual var sortingInfo = SortingInfo.Parse("anand_asc;manju_dsc"); var sortingItems = sortingInfo.Iterator(); // Assertions Assert.Equal(2, sortingInfo.Size()); Assert.Equal("anand", sortingItems[0].GetOrderBy()); Assert.Equal("manju", sortingItems[1].GetOrderBy()); }
public PageQuery(ICmsContext cmsContext) : base(cmsContext) { Sorting = new SortingInfo("Title", SortOrder.Descending); Paging = new PagerInfo(1, 20); AddProperty(Properties.PageType); AddProperty(Properties.AllowAnonymous); AddProperty(Properties.RequireSSL); AddProperty(Properties.Navigable); GetProperty(Properties.Title).SetOperator(QueryOperator.StartsWith); GetProperty(Properties.MenuName).SetOperator(QueryOperator.StartsWith); }
public void AddingItemWithParamShouldAddToList() { // Arrange var sortingInfo = new SortingInfo(); // Actual sortingInfo.Add("Param1", Sorting.Asc); sortingInfo.Add("Param2", Sorting.Dsc); // Assertions Assert.Equal(2, sortingInfo.Size()); }
// GET: /BrowseYearRanges/ public ActionResult Index() { SortingInfo info = new SortingInfo(); info.SortField = "Range"; info.SortDirection = "descending"; ViewBag.SortingInfo = info; return(View(db.YearRanges.OrderBy(y => y.Range).ToList())); }
private static SortingInfo GetSortingInfo(Request request) { SortingInfo sortingInfo = new SortingInfo(); var sortProp = request.Query.Sort; if (!string.IsNullOrEmpty(sortProp)) { sortingInfo.Property = sortProp; } return(sortingInfo); }
public ActionResult Index(SortingInfo info) { IQueryable <Movie> query = null; switch (info.SortField) { case "Title": query = (info.SortDirection == "ascending" ? db.Movies.OrderBy(c => c.Title) : db.Movies.OrderByDescending(c => c.Title)); break; case "Director": query = (info.SortDirection == "ascending" ? db.Movies.OrderBy(c => c.Director.Name) : db.Movies.OrderByDescending(c => c.Director.Name)); break; case "Year": query = (info.SortDirection == "ascending" ? db.Movies.OrderBy(c => c.Year) : db.Movies.OrderByDescending(c => c.Year)); break; case "YearRange": query = (info.SortDirection == "ascending" ? db.Movies.OrderBy(c => c.YearRange.Range) : db.Movies.OrderByDescending(c => c.YearRange.Range)); break; case "Price": query = (info.SortDirection == "ascending" ? db.Movies.OrderBy(c => c.Price) : db.Movies.OrderByDescending(c => c.Price)); break; case "Rating": query = (info.SortDirection == "ascending" ? db.Movies.OrderBy(c => c.Rating) : db.Movies.OrderByDescending(c => c.Rating)); break; } query = query.Skip(info.CurrentPageIndex * info.PageSize).Take(info.PageSize); ViewBag.SortingInfo = info; List <Movie> model = query.ToList(); return(View(model)); }
public static IQueryable <T> DataSorting <T>(this IQueryable <T> query, SortingInfo sorting = null) where T : class { if (sorting == null) { return(query); } if (string.IsNullOrWhiteSpace(sorting.Sort)) { return(query); } return(sorting.Direction == SortingDirection.ASC ? query.OrderBy(SortingExpression <T>(sorting)) : query.OrderByDescending(SortingExpression <T>(sorting))); }
public UserQuery(ICmsContext cmsContext) : base(cmsContext) { _cmsContext = cmsContext; Sorting = new SortingInfo(Properties.FirstName, SortOrder.Descending); Paging = new PagerInfo(1, Settings.General.PageSize); AddProperty(Properties.FirstName).SetIsLocalized(false).SetOperator(QueryOperator.StartsWith).SetList(); AddProperty(Properties.LastName).SetIsLocalized(false).SetOperator(QueryOperator.StartsWith).SetList(); AddProperty(Properties.Country).SetIsLocalized(false); AddProperty(Properties.FullName).SetIsLocalized(false); AddProperty(Properties.Locked); AddProperty(Properties.Deactived).SetDefaultValue("false"); AddProperty(Properties.Roles).SetList(); AddProperty(Properties.Email).SetIsLocalized(false); AddProperty(Properties.LabelAlias); }
public void AddingItemWithParamShouldAddToListAtIndex() { // Arrange var sortingInfo = new SortingInfo(); // Actual sortingInfo.Add(new SortingElement("Param1", Sorting.Asc)); sortingInfo.Add(new SortingElement("Param2", Sorting.Dsc)); sortingInfo.InsertAtIndex(0, "Param3", Sorting.Asc); sortingInfo.InsertAtIndex(0, "Param4", Sorting.Dsc); var sortingItems = sortingInfo.Iterator(); // Assertions Assert.Equal(4, sortingInfo.Size()); Assert.Equal("Param4", sortingItems[0].GetOrderBy()); Assert.Equal("Param3", sortingItems[1].GetOrderBy()); }
/// <summary> /// Gets the manager log book view for all employees for the given store and filter by activity. /// </summary> /// <param name="context">Request context.</param> /// <param name="storeNumber">Store number.</param> /// <param name="employeeActivityTypes">Employee activity types.</param> /// <param name="fromDateTimeOffset">The employee activity date and time offset lower bound.</param> /// <param name="toDateTimeOffset">The employee activity date and time offset upper bound.</param> /// <param name="pagingInfo">The paging information.</param> /// <param name="sortingInfo">The sorting information.</param> /// <returns>The results collection of employee activities.</returns> public static ReadOnlyCollection <EmployeeActivity> GetManagerLogbookView( RequestContext context, string storeNumber, EmployeeActivityType[] employeeActivityTypes, DateTimeOffset?fromDateTimeOffset, DateTimeOffset?toDateTimeOffset, PagingInfo pagingInfo, SortingInfo sortingInfo) { ThrowIf.Null(context, "context"); // Get the UTC date and time from the channel date and time offset var fromUtcDateTime = fromDateTimeOffset.GetUtcDateTime(); var toUtcDateTime = toDateTimeOffset.GetUtcDateTime(); // Get the store numbers the user is working at var storeIds = GetEmployeeStoreIds(context); bool storeNumberDefined = !string.IsNullOrWhiteSpace(storeNumber); if ((storeIds == null) || (storeNumberDefined && !storeIds.Contains(storeNumber))) { // if no store the user is assigned to, nor the input storeNumber is among the store(s) the user is assigned to return(null); } else if (storeNumberDefined) { // if the input store number is defined, use it directly storeIds = new[] { storeNumber }; } // Get the break activity categories var breakActivities = GetBreakActivityJobIds(context, employeeActivityTypes); var request = new GetManagerActivityHistoryRealtimeRequest( storeIds, employeeActivityTypes, breakActivities, fromUtcDateTime, toUtcDateTime, pagingInfo, sortingInfo); return(context.Execute <EntityDataServiceResponse <EmployeeActivity> >(request).PagedEntityCollection.Results); }
// GET: /GenreManager/ public ActionResult Index() { SortingInfo info = new SortingInfo(); info.SortField = "Title"; info.SortDirection = "descending"; info.PageSize = 10; info.PageCount = Convert.ToInt32(Math.Ceiling((double)(db.Movies.Count() / info.PageSize))); info.CurrentPageIndex = 0; var genres = db.Genres.OrderBy(g => g.Name).Take(info.PageSize); ViewBag.SortingInfo = info; List <Genre> model = genres.ToList(); return(View(genres)); }
public ActionResult Index(SortingInfo info) { IQueryable <Genre> query = null; switch (info.SortField) { case "Name": query = (info.SortDirection == "ascending" ? db.Genres.OrderBy(c => c.Name) : db.Genres.OrderByDescending(c => c.Name)); break; } query = query.Skip(info.CurrentPageIndex * info.PageSize).Take(info.PageSize); ViewBag.SortingInfo = info; List <Genre> model = query.ToList(); return(View(model)); }
public ActionResult Index() { SortingInfo info = new SortingInfo(); info.SortField = "Title"; info.SortDirection = "descending"; info.PageSize = 20; info.PageCount = Convert.ToInt32(Math.Ceiling((double)(db.Movies.Count() / info.PageSize))); info.CurrentPageIndex = 0; var movies = db.Movies.Include(m => m.Director).Include(m => m.YearRange).OrderBy(m => m.Title).Take(info.PageSize); ViewBag.SortingInfo = info; List <Movie> model = movies.ToList(); return(View(movies)); }
public void Default_sortinginfo_is_null_property_ascending_with_sorting_disabled() { var sortingInfo = new SortingInfo(); Assert.IsFalse(sortingInfo.SortingEnabled); Assert.IsNull(sortingInfo.SortProperty); Assert.AreEqual(SortOrder.Ascending, sortingInfo.Order); }