/// <summary>
        /// get a list of all port forwardings
        /// </summary>
        /// <returns></returns>
        public JsonResult Index(string apiKey, string name)
        {
            try
            {
                var apiKeyRepository = RepositoryFactory.ApiKeyRepository();
                var apiKeyId         = apiKeyRepository.GetApiKeyIdByCode(apiKey);

                var vmRepository = RepositoryFactory.VmRepository();
                var vm           = vmRepository.GetByName(name, apiKeyId);
                if (vm == null)
                {
                    return(Json(new { result = "not found" }, JsonRequestBehavior.AllowGet));
                }

                var portForwardingRepository = RepositoryFactory.PortForwardingRepository();

                var portForwardings = portForwardingRepository.GetByVm(vm.Id);

                return(Json(portForwardings, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new { result = e.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        /// <summary>
        /// List all available images
        /// </summary>
        /// <returns></returns>
        public JsonResult Index(string apiKey)
        {
            try
            {
                var apiKeyRepository = repositoryFactory.ApiKeyRepository();
                var apiKeyId         = apiKeyRepository.GetApiKeyIdByCode(apiKey);

                var imageRepository = repositoryFactory.ImageRepository();
                var vms             = imageRepository.GetByApiKey(apiKeyId);

                return(Json(vms, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new { result = e.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }