예제 #1
0
        public void PopulateClans(ClashContext context)
        {
            //if the db is empty it does nothing
            //I intend on populating the production DB Manually so nothing gets out of hand
            if (context.Clans.Count() > 0)
            {     //Returns all clans in DB ordered by Clan Tag
                var clans = context.Clans.OrderByDescending(c => c.Tag).ToList();

                //cycles through all clans in the DB ordered by Clan Tag
                clans.ForEach((c =>
                {
                    //if there's nothing in the List it immediately adds a value
                    if (Clans == null)
                    {
                        Clans = new List <Clan>();
                        Clans.Add(c);
                    }

                    //the recieved list is ordered by tag, it will only enter the first entry per tag by clan
                    if (Clans[Clans.Count() - 1].Tag != c.Tag)
                    {
                        Clans.Add(c);
                    }
                }));
                Clans = Clans.OrderByDescending(p => p.ClanScore).ToList();
            }
        }
예제 #2
0
        public void PopulatePlayers(ClashContext context)
        {
            //if the db is empty it does nothing
            //I intend on populating the production DB Manually so nothing gets out of hand
            if (context.Players.Count() > 0)
            {     //Returns all players in DB ordered by Player Tag
                var players = context.Players.OrderByDescending(p => p.Tag).ToList();

                //cycles through all players in the DB ordered by Player Tag
                players.ForEach((p =>
                {
                    //if there's nothing in the List it immediately adds a value
                    if (Players == null)
                    {
                        Players = new List <Player>();
                        Players.Add(p);
                    }

                    //the recieved list is ordered by tag, it will only enter the first entry per tag by player
                    if (Players[Players.Count() - 1].Tag != p.Tag)
                    {
                        Players.Add(p);
                    }
                }));
                Players = Players.OrderByDescending(p => p.Trophies).ToList();
            }
        }
예제 #3
0
 public void SetCards(ClashContext context)
 {
     Card1 = context.Cards.Find(Card1Id);
     Card2 = context.Cards.Find(Card2Id);
     Card3 = context.Cards.Find(Card3Id);
     Card4 = context.Cards.Find(Card4Id);
     Card5 = context.Cards.Find(Card5Id);
     Card6 = context.Cards.Find(Card6Id);
     Card7 = context.Cards.Find(Card7Id);
     Card8 = context.Cards.Find(Card8Id);
 }
예제 #4
0
        public async Task <bool> SaveToDBByClan(ClashContext context)
        {
            DateTime now = DateTime.Now;

            var clan = await ClashJson.GetClanData("#8CYPL8R");

            clan.UpdateTime = now;
            context.Clans.Add(clan);

            List <Player> playersToAdd = new List <Player>();
            List <Battle> battlesToAdd = new List <Battle>();
            int           savedBattles = 0;

            //fills the list of player data to add to the DB
            // for (int m = 0; m < clan.Members; m++)

            for (int m = 0; m < 15; m++)
            {
                //gets basic player
                var player = await ClashJson.GetPlayerData(clan.MemberList[m].Tag);

                player = await ClashDB.FillPlayerDBData(player);

                playersToAdd.Add(player);
            }


            context.Players.AddRange(playersToAdd);

            for (int p = 0; p < playersToAdd.Count(); p++)
            {
                var battles = await ClashJson.GetListOfBattles(playersToAdd[p].Tag);

                battles       = battles.ToList().GetRange(0, 10);
                savedBattles += await ClashDB.SaveBattles(battles);
            }


            await context.SaveChangesAsync();

            UpdateComplete = true;
            return(UpdateComplete);
        }
예제 #5
0
 public ClansModel(ClashContext c)
 {
     PopulateClans(c);
 }
예제 #6
0
 public PlayersModel(ClashContext context)
 {
     PopulatePlayers(context);
 }
예제 #7
0
 public ClashDB(ClashContext c)
 {
     context = c;
     //Player p = await GetPlayerData("#29PGJURQL");
 }