public async Task <bool> Delete(Producto v) { try { DB.Productos.Remove(v); await DB.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }
public async Task <Factura> Post(Factura v) { try { v.Id = Guid.NewGuid(); v.Fecha = DateTime.Now; foreach (var item in v.FacturaProductos) { item.Id = Guid.NewGuid(); item.FacturaId = v.Id; } await DB.Clientes.AddAsync(v.Cliente); await DB.Facturas.AddAsync(v); await DB.FacturaProductos.AddRangeAsync(v.FacturaProductos); await DB.SaveChangesAsync(); return(v); } catch (Exception e) { return(null); } }