public ActionResult SavePlayerToNewList(string PlayerId, string watchListName)
        {
            FFLToolEntities2 ORM = new FFLToolEntities2();

            string name          = watchListName;
            string userId        = User.Identity.GetUserId();
            string currWatchList = (from UW in ORM.tblUserWatchlists
                                    where UW.UserId == userId
                                    select UW.WatchlistId).Max().ToString();

            tblWatchlist watchList = new tblWatchlist();

            watchList.WatchlistId   = Convert.ToInt64(currWatchList);
            watchList.PlayerId      = Convert.ToInt32(PlayerId);
            watchList.WatchlistName = watchListName;

            try
            {
                ORM.tblWatchlists.Add(watchList);
                ORM.SaveChanges();
            }
            catch
            {
                return(RedirectToAction("ShowAllPlayers", new { watchListName = name }));
            }

            return(RedirectToAction("ShowAllPlayers", new { watchListName = name }));
        }
        public ActionResult SavePlayerToExistingList(string PlayerId, string watchListName)
        {
            string           name = watchListName;
            FFLToolEntities2 ORM  = new FFLToolEntities2();

            tblWatchlist watchlist = new tblWatchlist();

            watchlist.PlayerId      = Convert.ToInt32(PlayerId);
            watchlist.WatchlistName = watchListName.Trim();

            //need to error handle gracefully
            watchlist.WatchlistId = (from W in ORM.tblWatchlists
                                     where W.WatchlistName == watchListName.Trim()
                                     select W.WatchlistId).Distinct().Single();

            try
            {
                ORM.tblWatchlists.Add(watchlist);
                ORM.SaveChanges();
            }
            catch
            {
                return(RedirectToAction("ShowAllPlayers", new { watchListName = name }));
            }


            return(RedirectToAction("ShowAllPlayers", new { watchListName = name }));
        }
        public ActionResult ShowAllPlayers(string watchlistId, string watchListName)
        {
            string userId = User.Identity.GetUserId();

            if (userId == null)
            {
                return(View("../Account/Login"));
            }

            FFLToolEntities2 ORM       = new FFLToolEntities2();
            tblWatchlist     watchlist = new tblWatchlist();
            JObject          WatchList = new JObject();

            if (watchListName != null)
            {
                watchlist.WatchlistName = watchListName.Trim();

                //need to error handle gracefully
                watchlist.WatchlistId = (from W in ORM.tblWatchlists
                                         where W.WatchlistName == watchListName.Trim()
                                         select W.WatchlistId).Distinct().Single();

                WatchList = Table2(watchlist.WatchlistId.ToString());

                ViewBag.WatchListID = watchlist.WatchlistId;
            }


            JObject players = ApiRequest("?position=qb");

            ViewBag.Players        = players["cumulativeplayerstats"]["playerstatsentry"];
            ViewBag.UserWatchlists = DropdownWatchLists();

            if (WatchList != null && WatchList.Count != 0)
            {
                ViewBag.WatchList = WatchList["cumulativeplayerstats"]["playerstatsentry"];
            }

            ViewBag.WatchlistName = watchListName;

            if (watchListName != null)
            {
                ViewBag.WatchlistName = watchListName;
            }

            return(View("AllPlayersView"));
        }
        public ActionResult DropPlayer(string watchlistId, string playerId)
        {
            FFLToolEntities2 ORM = new FFLToolEntities2();

            tblWatchlist watchlist = ORM.tblWatchlists.Find(Convert.ToInt64(watchlistId), Convert.ToInt32(playerId));

            ORM.tblWatchlists.Remove(watchlist);
            ORM.SaveChanges();

            JObject delPlayerJSON = ApiRequestHistorical("current", "?player=" + playerId);
            string  delPlayer     = (string)delPlayerJSON["cumulativeplayerstats"]["playerstatsentry"][0]["player"]["FirstName"] + " " + (string)delPlayerJSON["cumulativeplayerstats"]["playerstatsentry"][0]["player"]["LastName"];

            return(RedirectToAction("WatchList", new
            {
                WatchlistId = watchlist.WatchlistId.ToString(),
                WatchlistName = watchlist.WatchlistName,
                DeletedPlayer = delPlayer
            }));
        }