コード例 #1
0
        public ActionResult Select()
        {
            ViewBag.Message = "API Key Query";

            ApiKeyManagement request = new ApiKeyManagement(ApiKey)
            {
                ExternalClientID = ExternalClientID
            };

            request.PrepareSelectRequest();

            return(SendRequest(request));
        }
コード例 #2
0
        public ActionResult Update()
        {
            ViewBag.Message = "API Key Update (set last key to INACTIVE)";

            ApiKeyManagement request = new ApiKeyManagement(ApiKey)
            {
                ExternalClientID = ExternalClientID
            };

            request.PrepareSelectRequest();

            string response;

            if (request.SendRequest(SharedKey, out response))
            {
                dynamic data = JsonConvert.DeserializeObject(response);

                if (data != null && data.apiKeys != null && data.apiKeys.Count > 1)
                {
                    int    index  = data.apiKeys.Count - 1;
                    string apiKey = data.apiKeys[index].key;

                    request.ApiKeyToUpdate = apiKey;
                    request.Status         = VisaHelper.Options.ApiKeyStatus.INACTIVE;
                    request.PrepareUpdateRequest();

                    return(SendRequest(request));
                }
                else
                {
                    TempData.Add("error", "Not enough keys to update, you must have at least 2 keys.");
                }
            }
            else
            {
                TempData.Add("error", string.Format("Could not query keys:\r\n{0}", response));
            }

            return(View());
        }