Exemplo n.º 1
0
        private void SendSet(DTOCard card)
        {
            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("http://localhost:7230/cards");

            wr.Method      = "POST";
            wr.ContentType = "application/json";
            using (var streamWriter = new StreamWriter(wr.GetRequestStream())) {
                string json = new JavaScriptSerializer().Serialize(card);
                //MessageBox.Show("SENDING: " + json);
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }
            try {
                HttpWebResponse resp     = (HttpWebResponse)wr.GetResponse();
                StreamReader    sr       = new StreamReader(resp.GetResponseStream());
                String          response = sr.ReadToEnd();
                //MessageBox.Show(response);
                int dmg = 0;
            }
            catch (Exception _e) {
                MessageBox.Show(_e.Message);
            }
        }
Exemplo n.º 2
0
        private DTOCard CardToDTOCard(Card _c)
        {
            DTOCard ret = new DTOCard();

            if (null != _c.aember)
            {
                ret.aember = int.Parse(_c.aember.Substring(_c.aember.IndexOf(' ')));
            }
            if (null != _c.power)
            {
                ret.power = int.Parse(_c.power.Substring(_c.power.IndexOf(' ')));
            }
            if (null != _c.armor)
            {
                ret.armor = int.Parse(_c.armor.Substring(_c.armor.IndexOf(' ')));
            }
            if (null != _c.artist)
            {
                if (_c.artist.Contains("Art by "))
                {
                    ret.artist = _c.artist.Substring(_c.artist.IndexOf("Art By ") + "Art By ".Length + 1);
                }
            }
            if (null != _c.house)
            {
                String[] houses = _c.house.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String s in houses)
                {
                    ret.houses.Add(s);
                }
            }
            if (null != _c.keyword)
            {
                String[] keywords = _c.keyword.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String s in keywords)
                {
                    ret.keywords.Add(s);
                }
            }
            if (null != _c.traits)
            {
                String[] traits = _c.traits.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String s in traits)
                {
                    ret.traits.Add(s);
                }
            }
            if (null != _c.setAndNumber)
            {
                String[] setAndNumber = _c.setAndNumber.Split(" #".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                ret.expansions.Add(_c.setAndNumber);//new CardExpansion(setAndNumber[0], int.Parse(setAndNumber[1])));
            }
            if (null != _c.name)
            {
                ret.name = System.Web.HttpUtility.HtmlDecode(Uri.UnescapeDataString(_c.name));
            }
            if (null != _c.text)
            {
                ret.text = System.Web.HttpUtility.HtmlDecode(Uri.UnescapeDataString(_c.text));
            }
            if (null != _c.type)
            {
                ret.type = _c.type;
            }
            if (null != _c.rarity)
            {
                ret.rarity = _c.rarity;
            }

            return(ret);
        }