public async Task <bool> Delete(ArticleId id, CancellationToken token = default) { id.VerifyNotNull(nameof(id)); _logger.LogTrace($"{nameof(Delete)}: Id={id}"); HttpResponseMessage response = await _httpClient.DeleteAsync($"api/article/{id.ToBase64()}", token); return(response.StatusCode switch { HttpStatusCode.OK => true, HttpStatusCode.NotFound => false, _ => throw new HttpRequestException($"Invalid http code={response.StatusCode}"), });
public async Task <ArticlePayload?> Get(ArticleId id, CancellationToken token = default) { id.VerifyNotNull(nameof(id)); _logger.LogTrace($"{nameof(Get)}: Id={id}"); try { return(await _httpClient.GetFromJsonAsync <ArticlePayload?>($"api/article/{id.ToBase64()}", token)); } catch (HttpRequestException ex) { _logger.LogError(ex, $"{nameof(Get)}: id={id} failed"); return(null); } }