Exemplo n.º 1
0
        // GET: Biotopes/biotopeKey
        public ActionResult Biotopes(RenderModel model, string key)
        {
            var env     = new Env();
            var url     = env.MICROSERVICE_URL + "/biotope/" + key;
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "GET";

            var biotopeModel = new BiotopeModel(model.Content)
            {
                Biotope             = null,
                Species             = null,
                BiotopeHierarchy    = null,
                SimilarBiotopes     = null,
                OldCodes            = null,
                HabitatCorrelations = null,
                Photos = null
            };

            try
            {
                var response = (HttpWebResponse)request.GetResponse();

                string content;
                using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    content = sr.ReadToEnd();
                }

                biotopeModel = GetBiotopeModel(content, model.Content);
            }
            catch (Exception)
            {
                return(View("Error", Umbraco.GetErrorPage()));
            }

            return(CurrentTemplate(biotopeModel));
        }