예제 #1
0
        internal static IEnumerable<AlbumInfo> GetAnswerCollection(int pageSize, int pageIndex, SortInfo objSorting, IEnumerable<AlbumInfo> resultsCollection)
        {
            var defaultResults = resultsCollection.Skip(pageSize * pageIndex).Take(pageSize).ToList();

            if (objSorting != null)
                switch (objSorting.Column)
                {
                    case "oldest":
                        switch (objSorting.Direction)
                        {
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.AlbumID descending, t.CreatedOnDate descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.AlbumID descending, t.CreatedOnDate ascending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                    case "active":
                        switch (objSorting.Direction)
                        {
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.AlbumID descending, t.LastModifiedOnDate descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.AlbumID descending, t.LastModifiedOnDate ascending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                    default: // "votes";
                        //CUONGVV
                        switch (objSorting.Direction)
                        {
                            // we always want the accepted answer first, then number of votes, and finally if 2+ answers have same number of votes, we want the newest one on top.
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.AlbumID descending, t.CreatedOnDate descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.AlbumID descending,t.CreatedOnDate descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                }
            return defaultResults;
        }
예제 #2
0
        internal static IEnumerable<TermInfo> GetTermCollection(int pageSize, int pageIndex, SortInfo objSorting, IEnumerable<TermInfo> resultsCollection)
        {
            var defaultResults = resultsCollection.Skip(pageSize * pageIndex).Take(pageSize).ToList();

            if (objSorting != null)
                switch (objSorting.Column)
                {
                    case "name":
                        switch (objSorting.Direction)
                        {
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.Name descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.Name ascending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                    case "popular":
                        switch (objSorting.Direction)
                        {
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.TotalTermUsage descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.TotalTermUsage ascending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                    case "newest":
                        switch (objSorting.Direction)
                        {
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.CreatedOnDate descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.CreatedOnDate ascending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                    default: // "daily";
                        switch (objSorting.Direction)
                        {
                            case Constants.SortDirection.Descending:
                                return (from t in resultsCollection orderby t.DayTermUsage descending select t).Skip(pageSize * pageIndex).Take(pageSize);
                            default:
                                return (from t in resultsCollection orderby t.DayTermUsage ascending select t).Skip(pageSize * pageIndex).Take(pageSize);
                        }
                }
            return defaultResults;
        }