Exemplo n.º 1
0
        public static async Task <TResponse> DeleteAsync <TResponse>(this IRequestClient client, string requestUri, Dictionary <string, string> headers = null)
        {
            var result = await client.DeleteAsync(requestUri, headers);

            result = result.EnsureSuccessStatusCode();
            return(JsonSerializer.Deserialize <TResponse>(result.Body.ToArray(), new JsonSerializerOptions {
                PropertyNameCaseInsensitive = true
            }));
        }
Exemplo n.º 2
0
        public async Task <bool> DeleteItemAsync(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(false);
            }

            var token = await _tokenProvider.GetToken();

            var headers = new Dictionary <string, string>
            {
                { "Authorization", $"Bearer {token}" }
            };

            var response = await _client.DeleteAsync($"api/Snippet/{id}", headers);

            response.EnsureSuccessStatusCode();

            return(true);
        }