BgEngine.Controllers.CommentController.Index C# (CSharp) Method

Index() private method

private Index ( int page, string sort, string sortdir ) : System.Web.Mvc.ViewResult
page int
sort string
sortdir string
return System.Web.Mvc.ViewResult
        public ViewResult Index(int? page, string sort, string sortdir)
        {
            ViewBag.RowsPerPage = BgResources.Pager_CommentsPerPage;
            ViewBag.TotalComments = CommentServices.TotalNumberOfEntity();
            ViewBag.AkismetInUse = (String.IsNullOrEmpty(BgResources.Akismet_API_key) ? false : true);
            var pageIndex = page ?? 0;
            bool dir;
            if (sortdir == null)
            {
                dir = false;
            }
            else
            {
                dir = sortdir.Equals("ASC", StringComparison.CurrentCultureIgnoreCase) ? true : false;
            }
            if (sort == null)
            {
                return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.DateCreated, false,"User"));
            }
            else
            {
                switch (sort.ToLower())
                {
                    case "commentid":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.CommentId, dir, "User"));
                    case "message":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.Message, dir, "User"));
                    case "isrelatedcomment":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.isRelatedComment, dir, "User"));
                    case "datecreated":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.DateCreated, dir, "User"));
                    case "dateupdated":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.DateUpdated, dir, "User"));
                    case "anonymoususer.username":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.AnonymousUser.Username, dir, "User"));
                    case "anonymoususer.email":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.AnonymousUser.Email, dir, "User"));
                    case "isspam":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.IsSpam, dir, "User"));
                    case "ip":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.Ip, dir, "User"));
                    case "useragent":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.UserAgent, dir, "User"));
                    case "post.title":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.Post.Title, dir, "User"));
                    case "post.code":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.Post.Code, dir, "User"));
                    case "user.username":
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.User.Username, dir, "User"));
                    default:
                        return View(CommentServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CommentsPerPage), c => c.DateCreated, false, "User"));
                }
            }
        }