private SortOption(SortProperties sort) { switch (sort) { case SortProperties.OriginalTitle: Description = "названию"; break; case SortProperties.Year: Description = "году"; break; case SortProperties.RatingIMDB: Description = "оценке IMDB"; break; case SortProperties.RatingUser: Description = "личной оценке"; break; case SortProperties.ViewDate: Description = "дате просмотра"; break; } SortProperty = sort; }
public QueryInfo <T> AddPaging(int pageSize, int page) { return(new QueryInfo <T>( SortProperties?.Cast <QuerySortProperty <T> >().ToArray(), Filters, new QueryPaging(pageSize, page), Includes)); }
public PageViewModel GetFolderContent(int moduleId, int folderId, int startIndex, int numItems, string sortExpression) { var folder = GetFolderInfo(folderId); if (!FolderPermissionController.CanBrowseFolder((FolderInfo)folder)) { //The user cannot access the content return(new PageViewModel { Folder = GetFolderViewModel(folder), Items = new List <ItemViewModel>(), TotalCount = 0 }); } var sortProperties = SortProperties.Parse(sortExpression); List <IFolderInfo> folders; var subfolderFilter = SettingsRepository.GetSubfolderFilter(moduleId); if (subfolderFilter != SubfolderFilter.IncludeSubfoldersFolderStructure) { folders = new List <IFolderInfo>(); } else { folders = GetFolders(folder, sortProperties.Column == "ItemName" ? "FolderName" : sortProperties.Column, sortProperties.Ascending).ToList(); } var recursive = subfolderFilter == SubfolderFilter.IncludeSubfoldersFilesOnly; var files = GetFiles(folder, sortProperties, startIndex, recursive).ToList(); IEnumerable <ItemViewModel> content; if (startIndex + numItems <= folders.Count()) { content = folders.Skip(startIndex).Take(numItems).Select(GetItemViewModel); } else if (startIndex >= folders.Count()) { content = files.Skip(startIndex - folders.Count).Take(numItems).Select(GetItemViewModel); } else { var numFiles = numItems - (folders.Count - startIndex); content = folders.Skip(startIndex).Select(GetItemViewModel).Union(files.Take(numFiles).Select(GetItemViewModel)); } return(new PageViewModel { Folder = GetFolderViewModel(folder), Items = content.ToList(), TotalCount = folders.Count() + files.Count() }); }
private IEnumerable <IFileInfo> GetFiles(IFolderInfo folder, SortProperties sortProperties, int startIndex, bool recursive) { Requires.NotNull("folder", folder); if (Host.EnableFileAutoSync && startIndex == 0) { FolderManager.Instance.Synchronize(folder.PortalID, folder.FolderPath, false, true); } return(SortFiles(FolderManager.Instance.GetFiles(folder, recursive, true), sortProperties)); }
public QueryInfo <T> AddSorting([NotNull] params QuerySortProperty[] sortings) { if (sortings == null) { throw new ArgumentNullException(nameof(sortings)); } return(new QueryInfo <T>( (SortProperties?.Cast <QuerySortProperty <T> >().ToArray() ?? new QuerySortProperty <T> [0]).Concat(sortings.Cast <QuerySortProperty <T> >()).ToArray(), Filters, Paging, Includes)); }
public QueryInfo <T> AddSorting([NotNull] Expression <Func <T, object> > sortExpression, bool ascending = true) { if (sortExpression == null) { throw new ArgumentNullException(nameof(sortExpression)); } return(new QueryInfo <T>( (SortProperties?.Cast <QuerySortProperty <T> >().ToArray() ?? new QuerySortProperty <T> [0]).Concat(new [] { new QuerySortProperty <T>(sortExpression, ascending) }).ToArray(), Filters, Paging, Includes)); }
public QueryInfo <T> AddFilter([NotNull] params QueryFilter[] filters) { if (filters == null) { throw new ArgumentNullException(nameof(filters)); } return(new QueryInfo <T>( SortProperties?.Cast <QuerySortProperty <T> >().ToArray(), (Filters ?? new QueryFilter[0]).Concat(filters).ToArray(), Paging, Includes)); }
public QueryInfo <T> AddFilter([NotNull] Expression <Func <T, bool> > filterExpression) { if (filterExpression == null) { throw new ArgumentNullException(nameof(filterExpression)); } return(new QueryInfo <T>( SortProperties?.Cast <QuerySortProperty <T> >().ToArray(), (Filters ?? new QueryFilter[0]).Concat(QueryFilter.Parse(filterExpression)).ToArray(), Paging, Includes)); }
public QueryInfo <T> AddIncludes([NotNull] params Expression <Func <T, object> >[] includeExpression) { if (includeExpression == null) { throw new ArgumentNullException(nameof(includeExpression)); } return(new QueryInfo <T>( SortProperties?.Cast <QuerySortProperty <T> >().ToArray(), Filters, Paging, (Includes ?? new string[0]).Concat(includeExpression.Select(e => EncodeMemberExpression(e.Body, e.Parameters[0]))).ToArray())); }
public void FindProducts() { using (var pc = PersistenceHelper.CreatePersistenceContext()) { var service = new ProductService(); var sortParams = new SortProperties <Product>() { { m => m.CreatedAt, SortOrder.Descending } }; long totalCount; var results = service.GetAll(0, 2, true, sortParams, out totalCount); } }
// GET: AuctionListViewModels public ActionResult Index() { SortProperties sp = new SortProperties() { id = "1", }; db = new AuctionListContext(sp, Enums.paramTypeForAuctionList.byCategories); var AuctionList = db.AuctionListView; ModelContainer cont = new ModelContainer(); cont.AddModel(AuctionList); return(View(cont)); }
public PageViewModel SearchFolderContent(int moduleId, int folderId, string pattern, int startIndex, int numItems, string sortExpression) { var recursive = SettingsRepository.GetSubfolderFilter(moduleId) != SubfolderFilter.ExcludeSubfolders; var folder = GetFolderInfo(folderId); var files = FolderManager.Instance.SearchFiles(folder, pattern, recursive); var sortProperties = SortProperties.Parse(sortExpression); var sortedFiles = SortFiles(files, sortProperties).ToList(); return(new PageViewModel { Folder = GetFolderViewModel(folder), Items = sortedFiles.Skip(startIndex).Take(numItems).Select(GetItemViewModel).ToList(), TotalCount = sortedFiles.Count() }); }
public static SortProperties Parse(string sortExpression) { var sortProperties = new SortProperties { Column = "ItemName", Ascending = true }; if (!string.IsNullOrEmpty(sortExpression)) { var se = sortExpression.Split(' '); if (se.Length == 2) { sortProperties.Column = se[0]; sortProperties.Ascending = se[1] == "ASC"; } } return sortProperties; }
public static SortProperties Parse(string sortExpression) { var sortProperties = new SortProperties { Column = "ItemName", Ascending = true }; if (!string.IsNullOrEmpty(sortExpression)) { var se = sortExpression.Split(' '); if (se.Length == 2) { sortProperties.Column = se[0]; sortProperties.Ascending = se[1] == "ASC"; } } return(sortProperties); }
internal void Sort(PropertyModel model) { PropertyViewModel prop = SortProperties.Find(p => p.Data == model); IEnumerable <SortDescription> result = Books.SortDescriptions.Cast <SortDescription>().Where(p => p.PropertyName == prop.Data.FullName); if (result != null && result.Count() == 1) { Books.SortDescriptions.Remove(result.First()); } else { Books.SortDescriptions.Add(new SortDescription(prop.Data.FullName, ListSortDirection.Ascending)); } RaisePropertyChanged("Books"); }
/// <inheritdoc/> public IList <IFileInfo> SearchFolderContent(int moduleId, IFolderInfo folder, bool recursive, string search, int pageIndex, int pageSize, string sorting, int moduleMode, out int totalCount) { var noPermissionMessage = Localization.GetExceptionMessage( "UserHasNoPermissionToBrowseFolder", Constants.UserHasNoPermissionToBrowseFolderDefaultMessage); if (!this.permissionsManager.HasFolderContentPermission(folder.FolderID, moduleMode)) { throw new FolderPermissionNotMetException(noPermissionMessage); } search = (search ?? string.Empty).Trim(); var files = FolderManager.Instance.SearchFiles(folder, search, recursive); var sortProperties = SortProperties.Parse(sorting); var sortedFiles = SortFiles(files, sortProperties).ToList(); totalCount = sortedFiles.Count; return(sortedFiles.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()); }
internal FavoriteSorting() { this.defaultSortProperty = Settings.Instance.DefaultSortProperty; }
public static SortedDictionary <string, FavoriteConfigurationElement> GetSortedFavorites(SortProperties SortProperty) { FavoriteConfigurationElementCollection favlist = GetFavorites(); if (favlist != null) { SortedDictionary <string, FavoriteConfigurationElement> favs = new SortedDictionary <string, FavoriteConfigurationElement>(); int counter = 0; foreach (FavoriteConfigurationElement fav in favlist) { string key = new string('a', counter); switch (SortProperty) { case SortProperties.ConnectionName: favs.Add(fav.Name + key, fav); break; case SortProperties.Protocol: favs.Add(fav.Protocol + key, fav); break; case SortProperties.ServerName: favs.Add(fav.ServerName + key, fav); break; case SortProperties.None: favs.Add(key, fav); break; default: break; } counter++; } return(favs); } return(null); }
public PagedResult <MovieData> GetMovies(object param, int page, int count, Filters filter, SortProperties sort) { using (var db = new Context()) { IQueryable <Movie> query = db.Movies; int uid = UAC.GetInstance().UserId; switch (sort) { case SortProperties.RatingUser: query = db.Viewings .Where(z => z.UserID == uid) .OrderByDescending(x => x.Rating) .Select(y => y.Movie); break; case SortProperties.ViewDate: query = db.Viewings .Where(z => z.UserID == uid) .OrderByDescending(x => x.Date) .Select(y => y.Movie); break; } switch (filter) { case Filters.GetByActor: if (param is PersonData) { query = query.Where(x => x.Actors.Exists(y => y.ActorId == (param as PersonData).ID)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByCountry: if (param is CountryData) { query = query.Where(x => x.Countries.Exists(y => y.CountryId == (param as CountryData).ID)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByDirector: if (param is PersonData) { query = query.Where(x => x.Directors.Exists(y => y.DirectorId == (param as PersonData).ID)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByScreenwriter: if (param is PersonData) { query = query.Where(x => x.Screenwriters.Exists(y => y.ScreenwriterId == (param as PersonData).ID)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByGenre: if (param is GenreData) { query = query.Where(x => x.Genres.Exists(y => y.GenreId == (param as GenreData).ID)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByStoryline: if (param is string) { query = query.Where(x => x.Storyline.Contains(param as string, StringComparison.OrdinalIgnoreCase)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByTitle: if (param is string) { query = query.Where(x => x.LocalizedTitle.Contains(param as string, StringComparison.OrdinalIgnoreCase) || x.OriginalTitle.Contains(param as string, StringComparison.OrdinalIgnoreCase)); } else { return(new PagedResult <MovieData>()); } break; case Filters.GetByYearPeriod: if (param is Tuple <short, short> ) { query = query.Where(x => x.Year >= (param as Tuple <short, short>).Item1 && x.Year <= (param as Tuple <short, short>).Item2); } else { return(new PagedResult <MovieData>()); } break; } switch (sort) { case SortProperties.OriginalTitle: query = query.OrderBy(x => x.OriginalTitle); break; case SortProperties.Year: query = query.OrderBy(x => x.Year); break; case SortProperties.RatingIMDB: query = query.OrderByDescending(x => x.RatingIMDB); break; } PagedResult <Movie> movies = query.GetPaged(page, count); return(new PagedResult <MovieData>() { CurrentPage = movies.CurrentPage, PageCount = movies.PageCount, PageSize = movies.PageSize, RowCount = movies.RowCount, Results = movies.Results.Select(x => new MovieData() { ID = x.ID, LocalizedTitle = x.LocalizedTitle, OriginalTitle = x.OriginalTitle, Year = x.Year, RatingIMDB = x.RatingIMDB }).ToList() }); } }
private static IEnumerable <IFileInfo> SortFiles(IEnumerable <IFileInfo> files, SortProperties sortProperties) { switch (sortProperties.Column) { case "ItemName": return(OrderBy(files, f => f.FileName, sortProperties.Ascending)); case "LastModifiedOnDate": return(OrderBy(files, f => f.LastModifiedOnDate, sortProperties.Ascending)); case "Size": return(OrderBy(files, f => f.Size, sortProperties.Ascending)); case "ParentFolder": return(OrderBy(files, f => f.FolderId, new FolderPathComparer(), sortProperties.Ascending)); case "CreatedOnDate": return(OrderBy(files, f => f.CreatedOnDate, sortProperties.Ascending)); default: return(files); } }
public SkillListGroupingStrategy(SortProperties props) { m_pSortProperties = props; }