public async Task <List <Hero> > Post([FromBody] HeroDeckPostModel heroDeckPost)
 {
     try
     {
         return(await _blc.GetHeroDeck(heroDeckPost));
     }
     catch (Exception ex)
     {
         throw new HttpRequestException(ex.Message);
     }
 }
Ejemplo n.º 2
0
        public async Task <List <Hero> > GetHeroDeck(HeroDeckPostModel heroDeckPost)
        {
            var heroDeck = new List <Hero>();

            var jsonContent = JsonConvert.SerializeObject(heroDeckPost);
            var content     = new StringContent(jsonContent);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            using (var response = await _http.PostAsync("HeroDeck", content))
            {
                if (!response.IsSuccessStatusCode)
                {
                    Console.WriteLine($"GetHeroDeck Error: {response.ReasonPhrase}");
                    throw new Exception($"GetHeroDeck Error: {response.ReasonPhrase}");
                }

                var stringResponse = await response.Content.ReadAsStringAsync();

                heroDeck = JsonConvert.DeserializeObject <List <Hero> >(stringResponse);
            }

            return(heroDeck);
        }
Ejemplo n.º 3
0
 public async Task <List <Hero> > GetHeroDeck(HeroDeckPostModel heroDeckPost)
 {
     return(await _dao.GetHeroDeck(heroDeckPost));
 }