Пример #1
0
        public async Task <CatalogItem> HandleAsync(CreateCatalogItemRequest catalogItem)
        {
            var catalogItemResult = new CatalogItem();

            var result = await _authService.HttpPost("catalog-items", catalogItem);

            if (result.StatusCode != HttpStatusCode.OK)
            {
                return(catalogItemResult);
            }

            catalogItemResult = JsonConvert.DeserializeObject <CreateCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem;

            return(catalogItemResult);
        }
Пример #2
0
        public async Task <CatalogItem> HandleAsync(CreateCatalogItemRequest catalogItem)
        {
            var catalogItemResult = new CatalogItem();

            var content = new StringContent(JsonConvert.SerializeObject(catalogItem), Encoding.UTF8, "application/json");

            var result = await _authService.GetHttpClient().PostAsync($"{Constants.API_URL}catalog-items", content);

            if (result.StatusCode != HttpStatusCode.OK)
            {
                return(catalogItemResult);
            }

            catalogItemResult = JsonConvert.DeserializeObject <CreateCatalogItemResult>(await result.Content.ReadAsStringAsync()).CatalogItem;

            return(catalogItemResult);
        }
Пример #3
0
 public async Task <CatalogItem> HandleAsync(CreateCatalogItemRequest catalogItem)
 {
     return((await _httpService.HttpPost <CreateCatalogItemResult>("catalog-items", catalogItem)).CatalogItem);
 }