public async Task <ResourceResultModel> GenerateHeader(SupportServiceResourceKey key, string id)
        {
            if (!_serviceConfiguration.ResourceExists(key))
            {
                return new ResourceResultModel {
                           StatusCode = HttpStatusCode.NotFound
                }
            }
            ;
            var resource  = _serviceConfiguration.GetResource(key);
            var headerKey = resource.HeaderKey ?? key;

            var headerResource = _serviceConfiguration.GetResource(headerKey);

            var uri = new Uri(_serviceConfiguration.FindSiteBaseUriForManfiestElement(_sites, headerKey),
                              headerResource.ResourceUrlFormat);

            var url = string.Format(uri.ToString(), id);

            return(await GetPage(url));
        }
        public async Task <ActionResult> Index(SupportServiceResourceKey key, string id, string childId)
        {
            id = id.ToUpper();
            if (!_serviceConfiguration.ResourceExists(key))
            {
                return(View("Sub",
                            new ResourceResultModel
                {
                    Resource = "<h3>This resource isn't registered</h3>",
                    StatusCode = HttpStatusCode.OK,
                    Exception = null
                }));
            }

            var resource = _serviceConfiguration.GetResource(key);

            if (resource.Challenge.HasValue)
            {
                if (!_checker.HasPermissions(Request, Response, User, $"{resource.Challenge}/{id}"))
                {
                    return(RedirectToAction("Challenge",
                                            new
                    {
                        resourceId = id,
                        resourceKey = (int)key,
                        challengeKey = (int)resource.Challenge,
                        url = Request.RawUrl
                    }));
                }
            }

            ViewBag.SubNav = await _repository.GetNav(key, id);

            ViewBag.SubHeader = await _repository.GenerateHeader(key, id);

            var resourceResult = await _repository.GetResourcePage(key, id, childId);

            return(View("Sub", resourceResult));
        }