//METODO PARA INSERIR ITENS NA LISTA DE CLIENTE(STORAGE) public void InserirDados(Produto produto, AuthenticatedUser user, int qta) { ListaDeProdCliente produtoAddCart = new ListaDeProdCliente(user.UserName, produto.Id.ToString()) { ProdutoId = produto.Id, Nome = produto.Nome, Quantidade = qta, Preco = produto.Preco, Url = produto.Url }; TableBatchOperation tableOperations = new TableBatchOperation(); tableOperations.InsertOrMerge(produtoAddCart); DadosStorage.Conection().ExecuteBatchAsync(tableOperations); }
//METODO PARA APAGAR UM ITEM DA TABLE DO CLIENTE SE ELIMINAR NO CARRINHO public async Task ApagarProdutoDaListaAsync(Produto produto, AuthenticatedUser user) { TableOperation tableOperation = TableOperation.Retrieve <ListaDeProdCliente>(user.UserName, produto.Id.ToString()); TableResult resultado = await Conection().ExecuteAsync(tableOperation); ListaDeProdCliente produtoAEliminar = resultado.Result as ListaDeProdCliente; TableBatchOperation tableOperations = new TableBatchOperation(); tableOperations.Delete(produtoAEliminar); await Conection().ExecuteBatchAsync(tableOperations); }