public IHttpActionResult BuildDeckByFaction(string factionAbbreviation) { List <Card> deck = SetupController.BuildDeck(factionAbbreviation); IEnumerable <Card> ieDeck = deck.AsEnumerable <Card>(); return(Ok(ieDeck)); }
/// <summary> /// Builds the player deck and hand using web service calls and adds to the player model /// </summary> /// <param name="player"></param> /// <param name="factionAbbreviation"></param> /// <returns></returns> public Player BuildDeckAndHand(Player player, string factionAbbreviation) { //Create web client to do call System.Net.WebClient client = new System.Net.WebClient(); //Create the url to pull from string deckUriString = Url.RouteUrl("", new { action = "builddeck/byfaction", controller = "Card", id = factionAbbreviation }, Request.Url.Scheme); string requestUri = deckUriString; //Get the deck and deserialize string deckReturn = client.DownloadString(requestUri); player.Deck = JsonConvert.DeserializeObject <List <Card> >(deckReturn); player.Hand = SetupController.DealHand(player.Deck, factionAbbreviation); //Same thing we always do, purge the dealt cards from the deck foreach (Card c in player.Hand) { player.Deck.Remove(c); } return(player); }