Ejemplo n.º 1
0
 private static void GetPayloadRanks(Payload payload, RanksController ranksController, SeasonWeeks seasonWeek)
 {
     payload.Ranks = ranksController.GetRanks(seasonWeek.SeasonWeekId);
 }
Ejemplo n.º 2
0
        public string GetRanksPayload(string uniqueId, int seasonWeekId, string ranks)
        {
            var payload = new Payload();

            WeeksController weeksController = new WeeksController();
            RanksController ranksController = new RanksController();

            var ownerExists = context.Owners.Where(o => o.UniqueId == uniqueId).First();

            var seasonWeek = new SeasonWeeks();
            if (seasonWeekId == -1)
            {
                seasonWeek = weeksController.GetSeasonWeek(DateTime.Now.ToShortDateString());
            }
            else
            {
                seasonWeek = weeksController.GetSeasonWeek(seasonWeekId);
            }

            GetPayloadRanks(payload, ranksController, seasonWeek);

            return Compression.Compress(JsonConvert.SerializeObject(payload));
        }
Ejemplo n.º 3
0
        public string GetUpdatePayload(string uniqueId, int seasonWeekId, string update)
        {
            var payload = new Payload();

            PlayerStatsController playerStatsController = new PlayerStatsController();
            PositionLimitsController positionLimitsController = new PositionLimitsController();
            OwnersController ownerController = new OwnersController();
            OwnerTeamsController ownerTeamsController = new OwnerTeamsController();
            WeeksController weeksController = new WeeksController();
            GamesController gamesController = new GamesController();
            PlayersController playersController = new PlayersController();
            RanksController ranksController = new RanksController();

            var ownerExists = context.Owners.Where(o => o.UniqueId == uniqueId).First();

            var seasonWeek = new SeasonWeeks();
            if (seasonWeekId == -1)
            {
                seasonWeek = weeksController.GetSeasonWeek(DateTime.Now.ToShortDateString());
            }
            else
            {
                seasonWeek = weeksController.GetSeasonWeek(seasonWeekId);
            }

            GetPayloadCurrentOwner(payload, playerStatsController, ownerController, ownerTeamsController, playersController, seasonWeek, uniqueId);

            GetPayloadOwners(payload, playerStatsController, ownerController, ownerTeamsController, playersController, seasonWeek);

            //GetPayloadPositionLimits(payload, positionLimitsController);

            //GetPayloadWeeks(payload, weeksController);

            GetPayloadGames(payload, gamesController, seasonWeek);

            //GetPayloadPlayers(payload, playersController, ownerExists);

            GetPayloadRanks(payload, ranksController, seasonWeek);

            return Compression.Compress(JsonConvert.SerializeObject(payload));
        }
Ejemplo n.º 4
0
        private StringBuilder ExportRanks()
        {
            WeeksController weeksController = new WeeksController();
            RanksController ranksController = new RanksController();
            var seasonWeek = weeksController.GetSeasonWeek(DateTime.Now.ToString());

            StringBuilder fileContents = new StringBuilder();

            #region Write Header
            fileContents.Append(string.Join(",", new[] {
                    "OwnerId",
                    "TeamName",
                    "OwnerName",
                    "DollarsMade",
                    "WeeksWon",
                    "TotalPoints",
                    "PayoutDollars",
                    "WeeksWonDollars",
                    "\r\n"
                }));
            #endregion

            #region Write File Contents
            ranksController.GetRanks(seasonWeek.SeasonWeekId).Select(os => string.Join(",", new string[] {
                os.OwnerId.ToString(),
                os.TeamName.ToString(),
                os.OwnerName.ToString(),
                os.DollarsMade.ToString(),
                string.Join(",", os.WeeksWon.OrderBy(ww => ww.WeekNum).Select(ww => ww.WeekNum)),
                os.TotalPoints.ToString(),
                os.PayoutDollars.ToString(),
                os.WeeksWonDollars.ToString(),
                "\r\n"
            }))
            .ToList()
            .ForEach(line => fileContents.Append(line));;
            #endregion

            return fileContents;
        }