Exemplo n.º 1
0
        public ActionResult Table(string sortOrder = "Asc", string sortBy = "" /*, string dynamicSortOrder = "Asc", string dynamicSortBy = ""*/)
        {
            try
            {
                var userInfoEntities = _userInfoServices.GetAll();
                if (userInfoEntities == null)
                {
                    return(View("Error", new HandleErrorInfo(new NullReferenceException(), "UserInfo", "Table")));
                }

                userInfoEntities = userInfoEntities.OrderByDescending(u => u.I_Points);
                userInfoEntities = userInfoEntities.ToList(); // avoid multiple enumeration

                ViewBag.BestDay      = _userInfoServices.GetTopBestDay();
                ViewBag.BestMonth    = _userInfoServices.GetTopBestMonth();
                ViewBag.BestPtsLastD = userInfoEntities.OrderByDescending(u => u.I_PtLastD).First();

                ViewBag.SortOrder = sortOrder;//(sortOrder == "Asc" ? "Desc" : "Asc");
                if (!string.IsNullOrEmpty(sortBy))
                {
                    return(View(SortUtility.SortUserInfoTable(userInfoEntities, sortBy, sortOrder)));
                }

                return(View(userInfoEntities));
            }
            catch (Exception e)
            {
                return(View("Error", new HandleErrorInfo(e, "UserInfo", "Table")));
            }
        }