// GET: Territory
        public async Task <ActionResult> List()
        {
            List <DisplayTerritoryModel> displayTerritories = new List <DisplayTerritoryModel>();
            IEnumerable <TerritoryModel> territories        = new List <TerritoryModel>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:62313");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync("api/territories");

                if (response.IsSuccessStatusCode)
                {
                    string temp = await response.Content.ReadAsStringAsync();

                    territories = JsonConvert.DeserializeObject <List <TerritoryModel> >(temp);
                }

                foreach (TerritoryModel model in territories)
                {
                    HouseModel         houseModel    = new HouseModel();
                    TerritoryTypeModel territoryType = new TerritoryTypeModel();

                    response = await client.GetAsync("api/houses/" + model.ID_House);

                    if (response.IsSuccessStatusCode)
                    {
                        string temp = await response.Content.ReadAsStringAsync();

                        houseModel = JsonConvert.DeserializeObject <HouseModel>(temp);
                    }

                    response = await client.GetAsync("api/territoriestypes/" + model.ID_Type);

                    if (response.IsSuccessStatusCode)
                    {
                        string temp = await response.Content.ReadAsStringAsync();

                        territoryType = JsonConvert.DeserializeObject <TerritoryTypeModel>(temp);
                    }

                    displayTerritories.Add(new DisplayTerritoryModel(model.ID, houseModel, territoryType));
                }
            }

            return(View(displayTerritories));
        }
 public DisplayTerritoryModel(int id, HouseModel owner, TerritoryTypeModel type)
 {
     ID    = id;
     Owner = owner;
     Type  = type;
 }