//public async Task<int> GetQuantity() //{ // var response = await _httpClient.GetAsync("/api/cart-quantity/"); // TreateErrorsResponse(response); // return await DeserializeObjectResponse<int>(response); //} public async Task <ResponseResult> UpdateItem(Guid idProduct, ItemCartDTO model) { var item = GetContent(model); var response = await _httpClient.PutAsync($"/api/cart/{model.IdProduct}", item); if (!TreateErrorsResponse(response)) { return(await DeserializeObjectResponse <ResponseResult>(response)); } return(ReturnOk()); }
public async Task <ResponseResult> AddItem(ItemCartDTO product) { var item = GetContent(product); var response = await _httpClient.PostAsync($"/api/cart/", item); if (!TreateErrorsResponse(response)) { return(await DeserializeObjectResponse <ResponseResult>(response)); } return(ReturnOk()); }
public async Task <ResponseErrorResult> UpdateProductCart(Guid produtoId, ItemCartDTO item) { var itemContent = GetContent(item); var response = await _httpClient.PutAsync($"/cart/{item.ProductId}", itemContent); if (!CheckErrorsResponse(response)) { return(await DeserializeObjectResponse <ResponseErrorResult>(response)); } return(ReturnOk()); }
public async Task <ResponseErrorResult> AddProductCart(ItemCartDTO item) { var itemContent = GetContent(item); var response = await _httpClient.PostAsync("/cart", itemContent); if (!CheckErrorsResponse(response)) { return(await DeserializeObjectResponse <ResponseErrorResult>(response)); } return(ReturnOk()); }
public async Task <IActionResult> UpdateItemToCart(Guid idProduct, ItemCartDTO itemCart) { var product = await _catalogService.Get(idProduct); await ValidateItemCart(product, itemCart.Quantity); if (!OperacaoValida()) { return(CustomResponse()); } var response = await _cartService.UpdateItem(idProduct, itemCart); return(CustomResponse(response)); }
public async Task <IActionResult> AddItemToCart(ItemCartDTO itemCart) { var product = await _catalogService.Get(itemCart.IdProduct); await ValidateItemCart(product, itemCart.Quantity); if (!OperacaoValida()) { return(CustomResponse()); } itemCart.Name = product.Name; itemCart.Price = product.Price; itemCart.Image = product.Image; var response = await _cartService.AddItem(itemCart); return(CustomResponse(response)); }