public async Task <IActionResult> Delete()
        {
            var form = await Request.ReadFormAsync();

            ApiKey key = _keyProvider.GetKey(form["id"]);

            if (key != null)
            {
                await _keyProvider.DeleteKey(key);
            }

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public object Get(string id)
        {
            SetAntiForgeryTokens();

            ApiKey key = _keyProvider.GetKey(id);

            if (key == null)
            {
                return(NotFound());
            }

            return(AccessTokenHelper.ToJsonModel(key));
        }
예제 #3
0
        public async Task <T> GetAsync <T>(params object[] args)
        {
            using (var client = new HttpClient()) {
                client.BaseAddress = new Uri("http://octopus.wehkamp.io/api/");
                client.DefaultRequestHeaders.Add("X-Octopus-ApiKey", keyProvider.GetKey());
                var response = await client.GetAsync(string.Join("/", args.Select(x => x.ToString()).ToArray()));

                response.EnsureSuccessStatusCode();
                var content = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <T>(content));
            }
        }