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); }