Ejemplo n.º 1
0
        public async Task <IEnumerable <Card> > PopulateDecklist(string[] CardNames)
        {
            var DeckList = new List <Card>();

            foreach (string card in CardNames)
            {
                int    quantity;
                string cardName;
                string setCode = "";

                var splitName = card.Split(' ');

                quantity = int.Parse(splitName[0][0].ToString());
                cardName = splitName[1];
                if (splitName.Length == 3)
                {
                    setCode = splitName[2];
                }

                var localDbCard = await localDbReader.GetCard(cardName, setCode);

                var convertedResult = CardConverter.LocalDBDataToCard(localDbCard);

                for (int i = 0; i < quantity; i++)
                {
                    DeckList.Add(convertedResult);
                }
            }

            return(DeckList);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <string> > InitialDBPopulation()
        {
            var thronesDbCards = await thronesDbProvider.GetAllCards();

            var JsonArrayCards   = JArray.Parse(thronesDbCards);
            var convertedResults = JsonArrayCards.Select(c => CardConverter.ThronesDBDataToCard(c)).AsEnumerable();

            return(await localDbWriter.UpdateDb(convertedResults));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <string> > UpdateDB(int SetCode)
        {
            var codeList = new List <string>();

            for (int i = 1; i < StaticValues.MaxSetSize; i++)
            {
                codeList.Add(String.Format("{0:D2}{1:D3}", SetCode, i));
            }
            var JsonArrayCards = new JArray();

            foreach (string code in codeList)
            {
                var thronesDbCard = await thronesDbProvider.GetSingleCard(code);

                JsonArrayCards.Add(JToken.Parse(thronesDbCard));
            }
            var convertedResults = JsonArrayCards.Select(c => CardConverter.ThronesDBDataToCard(c)).AsEnumerable();

            return(await localDbWriter.UpdateDb(convertedResults));
        }