public async Task <bool> actualizarDatos(PedidoModel producto) { var table = TablaAzure(); // Create a retrieve operation that takes a customer entity. TableOperation retrieveOperation = TableOperation .Retrieve <PedidoAzureEntity>(PedidoAzureEntity.PartitionFromRowID(producto.PedidoID), producto.PedidoID); // Execute the retrieve operation. TableResult retrievedResult = await table.ExecuteAsync(retrieveOperation); if (retrievedResult.Result != null) { var az = retrievedResult.Result as PedidoAzureEntity; az.Telefono = producto.Telefono; az.Cliente = producto.Cliente; az.FechaPedido = producto.FechaPedido; az.Precio = producto.Precio.ToString(); az.DescripcionProducto = producto.DescripcionProducto; az.Latitud = producto.Latitud; az.Longitud = producto.Longitud; az.Producto = producto.Producto; az.Estado = producto.Estado; var upOp = TableOperation.Replace(az); await table.ExecuteAsync(upOp); return(true); } else { return(false); } }
public async Task <string> IniciarPedido(PedidoModel nuevoPedido) { var table = TablaAzure(); // Create the table if it doesn't exist. var creada = await table.CreateIfNotExistsAsync(); var azEn = new PedidoAzureEntity(nuevoPedido.FechaPedido, nuevoPedido.Telefono); azEn.Cliente = nuevoPedido.Cliente; azEn.Telefono = nuevoPedido.Telefono; azEn.DescripcionProducto = nuevoPedido.DescripcionProducto; azEn.Estado = "N"; azEn.Producto = nuevoPedido.Producto; azEn.Precio = nuevoPedido.Precio.ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation = TableOperation.Insert(azEn); // Execute the insert operation. var x = await table.ExecuteAsync(insertOperation); return(azEn.RowKey); }
public async Task <List <PedidoModel> > LeerPedidosPorFecha(DateTime fecha) { var tabla = TablaAzure(); var particion = PedidoAzureEntity.PartitionKeyFromFecha(fecha); TableQuery <PedidoAzureEntity> query = new TableQuery <PedidoAzureEntity>() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, particion)); var token = new TableContinuationToken(); var list = new List <PedidoModel>(); foreach (PedidoAzureEntity az in await tabla.ExecuteQuerySegmentedAsync(query, token)) { list.Add(new PedidoModel() { PedidoID = az.PedidoID, Telefono = az.Telefono, Cliente = az.Cliente, FechaPedido = az.FechaPedido, Precio = decimal.Parse(az.Precio) }); } return(list); }