Exemplo n.º 1
0
        public ActionResult PoolerProfile(string userEmail, string displayName = "", string sortOrder = "Asc", string sortBy = "")
        {
            if (string.IsNullOrEmpty(userEmail))
            {
                return(View("Error", new HandleErrorInfo(new Exception("Malformed Request string param: userEmail"), "UserInfo", "PoolerProfile")));
            }

            try
            {
                var poolerChoices = _playerInfoServices.GetAllWhere(userEmail);
                if (poolerChoices == null)
                {
                    return(View("Error", new HandleErrorInfo(new NullReferenceException(), "UserInfo", "PoolerProfile")));
                }

                var userInfo = _userInfoServices.GetByEmail(userEmail);
                if (userInfo == null)
                {
                    return(View("Error", new HandleErrorInfo(new NullReferenceException(), "UserInfo", "PoolerProfile")));
                }


                ViewBag.DisplayName   = displayName;
                ViewBag.UserEmail     = userEmail;
                ViewBag.Pic           = userInfo.C_Pic;
                ViewBag.BestDay       = userInfo.I_BestDay;
                ViewBag.BestDayDate   = userInfo.D_BestDay;
                ViewBag.BestMonth     = userInfo.I_BestMonth;
                ViewBag.BestMonthDate = userInfo.D_BestMonth;
                ViewBag.PtsLastD      = userInfo.I_PtLastD;

                //ViewBag.UserInfo = userInfo;

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

                return(View(poolerChoices.OrderBy(p => p.I_Round)));
            }
            catch (Exception e)
            {
                return(View("Error", new HandleErrorInfo(e, "PlayerInfo", "Undrafted")));
            }
        }