public JsonResult Index(string key)
        {
            using (var db = new BiotopeDB())
            {
                db.Configuration.LazyLoadingEnabled   = true;
                db.Configuration.ProxyCreationEnabled = true;

                var biotope             = db.WEB_BIOTOPE.Where(b => b.BIOTOPE_KEY == key).ToList();
                var similarBiotopes     = db.WEB_BIOT_RELATION.Where(b => b.BIOTOPE_KEY == key).ToList();
                var oldCodes            = db.WEB_OLD_CODE.Where(b => b.BIOTOPE_KEY == key).ToList();
                var speciesGrab         = db.WEB_BIOT_SPECIES_GRAB.Where(b => b.BIOTOPE_KEY == key).ToList();
                var speciesObservation  = db.WEB_BIOT_SPECIES_OBSERVATION.Where(b => b.BIOTOPE_KEY == key).ToList();
                var habitatCorrelations = db.WEB_HABITAT_CORRELATION.Where(b => b.BIOTOPE_KEY == key).ToList();
                var photos = db.WEB_PHOTO.Where(b => b.BIOTOPE_KEY == key).ToList();

                var transferObject = new
                {
                    Biotope             = GetBiotopeDto(biotope[0]),
                    BiotopeHierarchy    = GetBiotopeHierarchyDto(biotope[0].WEB_BIOTOPE_HIERARCHY),
                    SimilarBiotopes     = GetSimilarBiotopesDto(similarBiotopes),
                    Species             = GetCharacterisingSpeciesDto(speciesGrab, speciesObservation),
                    OldCodes            = GetOldCodesDto(oldCodes),
                    HabitatCorrelations = GetHabitatCorrelationsDto(habitatCorrelations),
                    Photos = GetPhotosDto(photos)
                };

                return(Json(transferObject, JsonRequestBehavior.AllowGet));
            }
        }
        // GET: Biotope
        public JsonResult Index()
        {
            using (var db = new BiotopeDB())
            {
                var data = db.WEB_BIOTOPE_HIERARCHY.Select(b => new { b.BIOTOPE_KEY, b.BIOTOPE_PARENT_KEY, b.HIGHERLEVEL, b.LEVEL, b.WEB_BIOTOPE, b.WEB_BIOTOPE1 }).ToList();
                var parentChildHierarchy = new List <object>();

                foreach (var hierarchyLevel in data)
                {
                    if (hierarchyLevel.LEVEL == hierarchyLevel.HIGHERLEVEL + 1)
                    {
                        parentChildHierarchy.Add(new
                        {
                            BiotopeKey       = hierarchyLevel.BIOTOPE_KEY,
                            BiotopeParentKey = hierarchyLevel.BIOTOPE_PARENT_KEY,
                            FullTerm         = hierarchyLevel.WEB_BIOTOPE.FULL_TERM,
                            SortCode         = hierarchyLevel.WEB_BIOTOPE.SORT_CODE
                        });
                    }
                    else if (hierarchyLevel.LEVEL == 1 && hierarchyLevel.HIGHERLEVEL == 1)
                    {
                        parentChildHierarchy.Add(new
                        {
                            BiotopeKey       = hierarchyLevel.BIOTOPE_KEY,
                            BiotopeParentKey = hierarchyLevel.BIOTOPE_KEY,
                            FullTerm         = hierarchyLevel.WEB_BIOTOPE.FULL_TERM,
                            SortCode         = hierarchyLevel.WEB_BIOTOPE.SORT_CODE
                        });
                    }
                }

                return(Json(parentChildHierarchy, JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult Index()
 {
     using (var db = new BiotopeDB())
     {
         var biotopeCount = db.WEB_BIOTOPE.Count();
         var version      = typeof(WebApiApplication).Assembly.GetName().Version;
         return(Json(new { biotopeCount, version }, JsonRequestBehavior.AllowGet));
     }
 }