コード例 #1
0
ファイル: IdeationManager.cs プロジェクト: ka2ya/cityOfIdeas
        public Ideation GetIdeationWithReplies(int ideationId, string orderBy = "recent")
        {
            var ideation = _ideationRepository.ReadIdeationWithReplies(ideationId);

            if (ideation == null)
            {
                return(null);
            }

            switch (orderBy.ToLower())
            {
            case "recent":
                ideation.Replies.Sort((a, b) => DateTime.Compare(b.Created, a.Created));
                break;

            case "top":
                ideation.Replies.Sort((a, b) => b.Upvotes.CompareTo(a.Upvotes));
                break;

            case "trending":
                ideation.Replies = _trendingAlgorithm.GetTrendingList(ideation.Replies).Result.ToList();
                break;

            case "controversial":
                ideation.Replies.Sort((a, b) => b.Downvotes.CompareTo(a.Downvotes));
                break;
            }

            return(ideation);
        }