public static IQueryable <BookListDto> OrderBooksBy (this IQueryable <BookListDto> books, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: //#A return(books.OrderByDescending( //#A x => x.BookId)); //#A case OrderByOptions.ByVotes: //#B return(books.OrderByDescending(x => //#B x.ReviewsAverageVotes)); //#B case OrderByOptions.ByPublicationDate: //#C return(books.OrderByDescending( //#C x => x.PublishedOn)); //#C case OrderByOptions.ByPriceLowestFirst: //#D return(books.OrderBy(x => x.ActualPrice)); //#D case OrderByOptions.ByPriceHigestFirst: //#D return(books.OrderByDescending( //#D x => x.ActualPrice)); //#D default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public static IQueryable <PersonListDto> OrderPersonBy (this IQueryable <PersonListDto> Persons, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: return(Persons.OrderByDescending( x => x.Id)); case OrderByOptions.ByFirstName: return(Persons.OrderBy(x => x.FirstName)); case OrderByOptions.ByLastName: return(Persons.OrderBy(x => x.LastName)); case OrderByOptions.ByNationalId: return(Persons.OrderBy(x => x.NationalId)); default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public static IQueryable <FormDictionaryListDto> OrderFormDictionaryBy (this IQueryable <FormDictionaryListDto> formDics, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: return(formDics.OrderByDescending( x => x.Id)); case OrderByOptions.ByCode: return(formDics.OrderBy( x => x.Code)); case OrderByOptions.ByStationType: return(formDics.OrderBy( x => x.WorkPackageId)); case OrderByOptions.ByType: return(formDics.OrderBy( x => x.Type)); case OrderByOptions.ByPriority: return(formDics.OrderBy( x => x.Priority)); case OrderByOptions.ByPriorityDesc: return(formDics.OrderByDescending( x => x.Priority)); default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public static IQueryable <BookListDTO> OrderBooksBy( this IQueryable <BookListDTO> books, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: return(books.OrderByDescending(b => b.BookId)); case OrderByOptions.ByVotes: return(books.OrderByDescending(b => b.ReviewsAverageVotes)); case OrderByOptions.ByPublicationDate: return(books.OrderByDescending(b => b.PublishedOn)); case OrderByOptions.ByPriceLowestFirst: return(books.OrderBy(b => b.ActualPrice)); case OrderByOptions.ByPriceHigestFirst: return(books.OrderByDescending(b => b.ActualPrice)); default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public static IQueryable <DesciplineListDto> OrderDesciplineBy (this IQueryable <DesciplineListDto> desciplines, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: return(desciplines.OrderByDescending( x => x.Id)); case OrderByOptions.ByTitle: return(desciplines.OrderByDescending(x => x.Title)); case OrderByOptions.ByCreateDate: return(desciplines.OrderByDescending( x => x.CreatedDate)); case OrderByOptions.BySubSystemLowestFirst: return(desciplines.OrderBy(x => x.SubSystemCount)); case OrderByOptions.BySubSystemHigestFirst: return(desciplines.OrderByDescending( x => x.SubSystemCount)); default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public FileViewerViewModel() { base.DisplayName = Resources.MainWindowViewModel_Command_File_Utility; isGroupBy = false; isFilterFileName = false; isFilterSize = false; actionType = FileActionTypeOptions.Nothing; orderByDirection = OrderByDirectionOptions.Ascending; orderBy = OrderByOptions.Filename; this.PreviewCommand = new RelayCommand(this.OnPreview, this.IsFolderSelected); this.RunCommand = new RelayCommand(this.OnRun, this.IsActionSelected); this.BrowseCopyToCommand = new RelayCommand(this.OnBrowseCopyTo, this.IsBrowseEnabled); this.BrowseMoveToCommand = new RelayCommand(this.OnBrowseMoveTo, this.IsBrowseEnabled); folders = new ObservableCollection <TreeViewItemViewModel>(); foreach (DriveInfo di in DriveInfo.GetDrives()) { folders.Add(new TreeViewItemViewModel(di.RootDirectory, null, true)); } this.FileSizeByOptions = new ObservableCollection <string>() { "<", ">" }; }
public async Task TestOrderByOk(OrderByOptions orderBy) { //SETUP using (var context = new SqlDbContext(_options)) { var service = new SqlListBooksService(context); //ATTEMPT var books = await service.SortFilterPage(new SqlSortFilterPageOptions { OrderByOptions = orderBy }).ToListAsync(); //VERIFY } }
public static IQueryable <ContractorListDto> OrderContractorBy (this IQueryable <ContractorListDto> contractors, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: return(contractors.OrderBy(x => x.Id)); case OrderByOptions.ByPhoneNumber: return(contractors.OrderBy(x => x.PhoneNumber)); default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public async Task TestOrderByOk(OrderByOptions orderBy) { //SETUP using (var context = new NoSqlDbContext(_options)) { var service = new ListNoSqlBooksService(context); //ATTEMPT var books = await(service.SortFilterPageAsync(new NoSqlSortFilterPageOptions { OrderByOptions = orderBy })); //VERIFY books.Any().ShouldBeTrue(); } }
private IQueryable <Book> CreateOrderByExpression(IQueryable <Book> query, OrderByOptions orderByoption) { switch (orderByoption) { case OrderByOptions.author: query = query.OrderBy(b => b.Author.Name); break; case OrderByOptions.publisher: query = query.OrderBy(b => b.Publisher.Name); break; default: query = query.OrderBy(b => b.Title); break; } return(query); }
/// <summary> /// Searches for status files in target path and returns list of dataMessage objects /// </summary> /// <param name="messageStatus">Data message status for found files</param> /// <param name="path">Path to search</param> /// <param name="searchPatterns">File pattern</param> /// <param name="searchOption">Search option</param> /// <param name="sortBy">Sort by field</param> /// <param name="reverse">Order of files</param> /// <returns>List of dataMessage objects</returns> public static IEnumerable <DataMessage> GetStatusFiles(MessageStatus messageStatus, string path, string searchPatterns = "*.Status", SearchOption searchOption = SearchOption.AllDirectories, OrderByOptions sortBy = OrderByOptions.Created, bool reverse = false) { var dir = new DirectoryInfo(path); var sortByProperty = string.Empty; switch (sortBy) { case OrderByOptions.Created: sortByProperty = @"CreationTimeUtc"; break; case OrderByOptions.Modified: sortByProperty = @"LastWriteTimeUtc"; break; case OrderByOptions.Size: sortByProperty = @"Length"; break; case OrderByOptions.FileName: sortByProperty = @"FullName"; break; } foreach (FileInfo fileName in dir.EnumerateFiles(searchPatterns, searchOption).Sort(sortByProperty, reverse) ) { DataMessage dataMessage; using (var file = File.OpenText(fileName.FullName)) { var serializer = new JsonSerializer(); dataMessage = (DataMessage)serializer.Deserialize(file, typeof(DataMessage)); } yield return(dataMessage); } }
public static IQueryable <WorkPackageStepListDto> OrderWorkPackageStep (this IQueryable <WorkPackageStepListDto> workSteps, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.SimpleOrder: return(workSteps.OrderByDescending( x => x.Id)); case OrderByOptions.ByName: return(workSteps.OrderByDescending( x => x.Title)); case OrderByOptions.ByWorkPackage: return(workSteps.OrderByDescending( x => x.WorkPackageId)); default: throw new ArgumentOutOfRangeException( nameof(orderByOptions), orderByOptions, null); } }
public void OrderBooksBy(OrderByOptions orderByOptions) { //SETUP var inMemDb = new SqliteInMemory(); const int numBooks = 5; using (var db = inMemDb.GetContextWithSetup()) { db.SeedDatabaseDummyBooks(numBooks); //ATTEMPT var service = new ListBooksService(db); var listOptions = new SortFilterPageOptions() { OrderByOptions = orderByOptions }; var dtos = service.SortFilterPage(listOptions).ToList(); //VERIFY dtos.Count.ShouldEqual(numBooks); } }
public async Task OrderBooksBy(OrderByOptions orderByOptions) { //SETUP var numBooks = 5; var options = SqliteInMemory.CreateOptions <BookDbContext>(); using (var context = new BookDbContext(options)) { context.Database.EnsureCreated(); context.SeedDatabaseDummyBooks(numBooks); //ATTEMPT var service = new ListBooksService(context); var listOptions = new SortFilterPageOptions() { OrderByOptions = orderByOptions }; var dtos = await(await service.SortFilterPageAsync(listOptions)).ToListAsync(); //VERIFY dtos.Count.ShouldEqual(numBooks); } }
/************************************************************ #A Because of paging we always need to sort. I default to showing latest entries first #B This orders the book by votes. Books without any votes (null return) go at the bottom #C Order by publication date - latest books at the top #D Order by actual price, which takes into account any promotional price - both lowest first and highest first * ********************************************************/ public static IQueryable <ArticleDto> OrderArticlesBy(this IQueryable <ArticleDto> articles, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.NoOrder: return(articles.OrderByDescending(x => x.ArticleId)); //case OrderByOptions.ByVotes: // return books.OrderByDescending(x => x.ReviewsAverageVotes); case OrderByOptions.ByPublicationDate: return(articles.OrderByDescending(x => x.PublishedDate)); //case OrderByOptions.ByPriceLowestFirst: // return books.OrderBy(x => x.ActualPrice); //case OrderByOptions.ByPriceHigestFirst: // return books.OrderByDescending(x => x.ActualPrice); default: throw new ArgumentOutOfRangeException(nameof(orderByOptions), orderByOptions, null); } }
public static IQueryable <ProduktDto> OrderProduktsBy(this IQueryable <ProduktDto> produkt, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.ByNameAsc: return(produkt.OrderBy(x => x.Navn)); case OrderByOptions.ByNameDesc: return(produkt.OrderByDescending(x => x.Navn)); case OrderByOptions.ByPriceDesc: return(produkt.OrderBy(x => x.Pris)); case OrderByOptions.ByPriceAsc: return(produkt.OrderByDescending(x => x.Pris)); default: throw new ArgumentOutOfRangeException(nameof(orderByOptions), orderByOptions, null); } }
public static IQueryable <ProduktListDto> OrderProduktBy(this IQueryable <ProduktListDto> produkter, OrderByOptions orderByOptions) { switch (orderByOptions) { case OrderByOptions.Navn: return(produkter.OrderBy(x => x.ProduktNavn)); case OrderByOptions.Pris: return(produkter.OrderBy(x => x.Pris)); default: throw new ArgumentOutOfRangeException(nameof(orderByOptions), orderByOptions, null); } }
public QueryFilterOptions() { this.PagingOptions = new PagingOptions(); this.OrderByOptions = new OrderByOptions(); }
/// <summary> /// Searches for source files in target path and returns list of dataMessage objects /// </summary> /// <param name="messageStatus">Data message status for found files</param> /// <param name="path">Path to search</param> /// <param name="searchPatterns">File pattern</param> /// <param name="searchOption">Search option</param> /// <param name="sortBy">Sort by field</param> /// <param name="reverse">Order of files</param> /// <returns>List of dataMessage objects</returns> public static IEnumerable <DataMessage> GetFiles(MessageStatus messageStatus, string path, string searchPatterns = "*.*", SearchOption searchOption = SearchOption.AllDirectories, OrderByOptions sortBy = OrderByOptions.Created, bool reverse = false) { var dir = new DirectoryInfo(path); var sortByProperty = string.Empty; switch (sortBy) { case OrderByOptions.Created: sortByProperty = @"CreationTimeUtc"; break; case OrderByOptions.Modified: sortByProperty = @"LastWriteTimeUtc"; break; case OrderByOptions.Size: sortByProperty = @"Length"; break; case OrderByOptions.FileName: sortByProperty = @"FullName"; break; } foreach (FileInfo fileName in dir.EnumerateFiles(searchPatterns, searchOption).Sort(sortByProperty, reverse) ) { var dataMessage = new DataMessage { Name = fileName.Name, FullPath = fileName.FullName, MessageStatus = messageStatus }; yield return(dataMessage); } }