public async Task <BasketDto> Basket(AddToBasketDto addToBasketDto) { addToBasketDto.CustomerId = Convert.ToInt32(accessor.HttpContext.Request.Cookies["customer"]); var stringContent = new StringContent(JsonConvert.SerializeObject(addToBasketDto), Encoding.UTF8, "application/json"); var responseMessage = await client.PostAsync("Auth/AddToBasket", stringContent); if (responseMessage.IsSuccessStatusCode) { var basketDto = JsonConvert .DeserializeObject <BasketDto>(await responseMessage.Content.ReadAsStringAsync()); accessor.HttpContext.Response.Cookies.Append("customer", basketDto.customerId.ToString()); return(basketDto); } else { return(null); } }
public async Task <IActionResult> AddBasket(AddToBasketDto addToBasketDto) { var a = await basketApiService.Basket(addToBasketDto); return(Json(a)); }