public IHttpActionResult GetApp(string appId)
 {
     try
     {
         return(Ok(_applicationManager.Get(appId)));
     }
     catch (ApplicationHostException ex)
     {
         return(ex.NotFound
             ? (IHttpActionResult)NotFound()
             : BadRequest(ex.Message));
     }
 }
        private IHttpActionResult GetRootContent(string aliasOrAppId)
        {
            HostedApplication app = null;

            try
            {
                app = _applicationManager.Get(aliasOrAppId);
            }
            catch (ApplicationHostException)
            {
                try
                {
                    app = _applicationManager.FromAlias(aliasOrAppId);
                }
                catch (ApplicationHostException)
                {
                    app = _applicationManager.DefaultApp;
                }
            }

            if (app == null)
            {
                return(SendResource(ReadTextResource("NoTenantRoot.html"), "text/html"));
            }

            var appRoot = GetApplicationRoot(app.Meta);

            var resource = string.IsNullOrWhiteSpace(appRoot)
                ? ReadTextResource("TenantRoot.html")
                : ReadTextContent(appRoot);

            resource = resource.Replace("[[TenantName]]", app.Meta.Name);
            resource = resource.Replace("[[TenantAppId]]", app.AppId.ToString());

            return(SendResource(resource, "text/html"));
        }