Esempio n. 1
0
        public async Task <IActionResult> GetTheCharacter(string id)
        {
            if (HttpContext.Request.Method == "POST")
            {
                string session_id = CookieManager.Session(HttpContext);

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://anapioficeandfire.com");
                var response = await client.GetAsync($"/api/characters/{id}");//this will return the character based on their id

                gotcharacter newCharacter = await response.Content.ReadAsAsync <gotcharacter>();

                newCharacter.SessionID = session_id;

                newCharacter.Create();

                return(View(newCharacter));
            }
            else
            {
                string session_id = CookieManager.Session(HttpContext);

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://anapioficeandfire.com");
                var response = await client.GetAsync($"/api/characters/{id}");//this will return the character based on their id

                gotcharacter newCharacter = await response.Content.ReadAsAsync <gotcharacter>();

                newCharacter.SessionID = session_id;

                return(View(newCharacter));
            }
        }
Esempio n. 2
0
        public async Task <House> GetHouse(int houseID)
        {
            CookieManager.Session(HttpContext);

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://anapioficeandfire.com");
            var response = await client.GetAsync($"/api/houses/{houseID}");//this will return the character based on their id

            House house = await response.Content.ReadAsAsync <House>();

            List <gotcharacter> characterList = new List <gotcharacter>();

            foreach (string url in house.SwornMembers)
            {
                gotcharacter character = await GetTheCharacterByurl(url);

                characterList.Add(character);
            }

            house.characters = characterList.ToArray();

            return(house);
        }