más cambios ahora funciona el tema de las facturas pero no el emailer

This commit is contained in:
fedpo
2024-10-01 02:48:17 +01:00
parent 37ff7022cf
commit 76d9b597d6
30 changed files with 156 additions and 6617 deletions

View File

@@ -12,16 +12,10 @@ namespace Controladora
repositorioFacturas = new(new Context());
}
private bool ExistePorId(int id)
{
var fac = repositorioFacturas.ObtenerPorId(id);
return (fac.Id == id);
}
public string Añadir(Factura t)
{
if (t == null) return "La Factura es nula, fallo la carga";
if (ExistePorId(t.Id)) return $"La Factura con el ID {t.Id} ya existe";
if (t.Cliente == null || t.Cliente.Cuit == 0) return "Debe seleccionar un cliente antes de agregar la factura";
string checkstock = "";
@@ -41,7 +35,8 @@ namespace Controladora
{
repositorioFacturas.Add(t);
bool resultado = repositorioFacturas.Guardar();
string resultadolote = ControladoraLotes.Instance.DisminuirStock(t.MostrarDetalles());
t = ObtenerPorId(t);
string resultadolote = ControladoraLotes.Instance.DisminuirStock(t);
// Convierte ReadOnlyCollection a List
var detallesList = new List<DetalleFactura>(t.MostrarDetalles());
@@ -78,6 +73,11 @@ namespace Controladora
.AsReadOnly();
}
public Factura ObtenerPorId(Factura fac)
{
return repositorioFacturas.ObtenerPorId(fac);
}
public ReadOnlyCollection<DetalleFactura> ListarDetallesFactura(Factura factura)
{
Factura facturaalistar = ControladoraFacturas.Instance.Listar().First(x => x.Id == factura.Id);

View File

@@ -18,18 +18,17 @@ namespace Controladora
repositorioLotes = new(new Context());
}
public string DisminuirStock(ReadOnlyCollection<DetalleFactura> detalleFactura)
public string DisminuirStock(Factura factura)
{
var ret = false;
foreach (var detalle in detalleFactura)
foreach (var detalle in factura.Detalles)
{
if (detalle == null) return "El detalle es nulo";
if (detalle.Producto.Id < 0) return "Esta mal cargada la Id de producto";
var productos = ControladoraProductos.Instance.Listar();
if (!productos.Any(x => x.Id == detalle.Producto.Id)) return "No hay Productos con esa id";
ret = repositorioLotes.DisminuirStock(detalle);
}
var ret = repositorioLotes.DisminuirStock(factura);
repositorioLotes.Guardar();
return (ret) ?
"Se Descontaron los productos":

View File

@@ -14,5 +14,13 @@ namespace Entidades
return Producto.Precio * Cantidad;
}
}
public string NombreProducto
{
get
{
return Producto.Nombre;
}
}
}
}

View File

@@ -4,32 +4,45 @@ namespace Entidades
{
public class Factura
{
public int Id { get; set; }
public double Total { get; set; }
public DateTime Fecha { get; set; }
public int Id { get; set; }
public double Total { get; set; }
public DateTime Fecha { get; set; }
public long IdCliente { get; set; }
public Cliente Cliente { get; set; }
public long IdCliente { get; set; }
public Cliente Cliente { get; set; }
private List<DetalleFactura> detalles = new List<DetalleFactura>();
public ReadOnlyCollection<DetalleFactura> Detalles => detalles.AsReadOnly();
public List<DetalleFactura> Detalles = new List<DetalleFactura>();
public void AñadirDetalle(DetalleFactura detalle)
public string NombreCliente
{
get
{
detalles.Add(detalle);
}
public bool EliminarDetalle(DetalleFactura detalle)
{
var aeliminar = detalles.Find(x => x.Id == detalle.Id);
if (aeliminar == null) return false;
return detalles.Remove(aeliminar);
}
public ReadOnlyCollection<DetalleFactura> MostrarDetalles()
{
return detalles.AsReadOnly();
return Cliente.NombreCompleto;
}
}
public long Cuit
{
get
{
return Cliente.Cuit;
}
}
public void AñadirDetalle(DetalleFactura detalle)
{
Detalles.Add(detalle);
}
public bool EliminarDetalle(DetalleFactura detalle)
{
var aeliminar = Detalles.Find(x => x.Id == detalle.Id);
if (aeliminar == null) return false;
return Detalles.Remove(aeliminar);
}
public ReadOnlyCollection<DetalleFactura> MostrarDetalles()
{
return Detalles.AsReadOnly();
}
}
}

View File

@@ -1,29 +0,0 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240812181354_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -1,591 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240826212726_nuevasrelaciones")]
partial class nuevasrelaciones
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Cuit"));
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("IdProducto");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Cuit"));
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("IdProveedor")
.HasColumnType("int");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<int>("ProductoId")
.HasColumnType("int");
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.HasKey("ProductoId", "ProveedorId");
b.HasIndex("ProveedorId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("int");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("IdProducto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("Detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("Detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,443 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class nuevasrelaciones : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Categoria",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Descripcion = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Categoria", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Clientes",
columns: table => new
{
Cuit = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nombre = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Apellido = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Direccion = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Correo = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
Habilitado = table.Column<bool>(type: "bit", nullable: false, defaultValue: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Clientes", x => x.Cuit);
});
migrationBuilder.CreateTable(
name: "Producto",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nombre = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Precio = table.Column<double>(type: "float", nullable: false),
Habilitado = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
EsPerecedero = table.Column<bool>(type: "bit", nullable: false),
Discriminator = table.Column<string>(type: "nvarchar(21)", maxLength: 21, nullable: false),
TipoDeEnvase = table.Column<string>(type: "nvarchar(max)", nullable: true),
MesesHastaConsumoPreferente = table.Column<int>(type: "int", nullable: true),
MesesHastaVencimiento = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Producto", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Proveedores",
columns: table => new
{
Cuit = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nombre = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
RazonSocial = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
Direccion = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
Habilitado = table.Column<bool>(type: "bit", nullable: false, defaultValue: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Proveedores", x => x.Cuit);
});
migrationBuilder.CreateTable(
name: "Facturas",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Total = table.Column<double>(type: "float", nullable: false),
Fecha = table.Column<DateTime>(type: "datetime2", nullable: false),
IdCliente = table.Column<long>(type: "bigint", nullable: false),
ClienteCuit = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Facturas", x => x.Id);
table.ForeignKey(
name: "FK_Facturas_Clientes_ClienteCuit",
column: x => x.ClienteCuit,
principalTable: "Clientes",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductoCategoria",
columns: table => new
{
CategoriaId = table.Column<int>(type: "int", nullable: false),
ProductoId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductoCategoria", x => new { x.CategoriaId, x.ProductoId });
table.ForeignKey(
name: "FK_ProductoCategoria_Categoria_CategoriaId",
column: x => x.CategoriaId,
principalTable: "Categoria",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductoCategoria_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrdenDeCompras",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProveedorCuit = table.Column<long>(type: "bigint", nullable: false),
IdProveedor = table.Column<long>(type: "bigint", nullable: false),
Entregado = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrdenDeCompras", x => x.Id);
table.ForeignKey(
name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit",
column: x => x.ProveedorCuit,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Presupuestos",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Fecha = table.Column<DateTime>(type: "datetime2", nullable: false),
Habilitado = table.Column<bool>(type: "bit", nullable: false),
Aceptado = table.Column<bool>(type: "bit", nullable: false),
ProveedorCuit = table.Column<long>(type: "bigint", nullable: false),
IdProveedor = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Presupuestos", x => x.Id);
table.ForeignKey(
name: "FK_Presupuestos_Proveedores_ProveedorCuit",
column: x => x.ProveedorCuit,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductoProveedor",
columns: table => new
{
ProductoId = table.Column<int>(type: "int", nullable: false),
ProveedorId = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductoProveedor", x => new { x.ProductoId, x.ProveedorId });
table.ForeignKey(
name: "FK_ProductoProveedor_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductoProveedor_Proveedores_ProveedorId",
column: x => x.ProveedorId,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Remitos",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProveedorCuit = table.Column<long>(type: "bigint", nullable: false),
IdProveedor = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Remitos", x => x.Id);
table.ForeignKey(
name: "FK_Remitos_Proveedores_ProveedorCuit",
column: x => x.ProveedorCuit,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetallesFacturas",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
IdFactura = table.Column<int>(type: "int", nullable: false),
Cantidad = table.Column<int>(type: "int", nullable: false),
IdProducto = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetallesFacturas", x => new { x.Id, x.IdFactura });
table.ForeignKey(
name: "FK_DetallesFacturas_Facturas_IdFactura",
column: x => x.IdFactura,
principalTable: "Facturas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetallesFacturas_Producto_IdProducto",
column: x => x.IdProducto,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetalleOrdenDeCompras",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
IdOrdenDeCompra = table.Column<int>(type: "int", nullable: false),
MontoCU = table.Column<double>(type: "float", nullable: false),
IdPresupuesto = table.Column<int>(type: "int", nullable: false),
Cantidad = table.Column<int>(type: "int", nullable: false),
ProductoId = table.Column<int>(type: "int", nullable: false),
IdProducto = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetalleOrdenDeCompras", x => new { x.Id, x.IdOrdenDeCompra });
table.ForeignKey(
name: "FK_DetalleOrdenDeCompras_OrdenDeCompras_IdOrdenDeCompra",
column: x => x.IdOrdenDeCompra,
principalTable: "OrdenDeCompras",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetalleOrdenDeCompras_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetallePresupuestos",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
IdPresupuesto = table.Column<int>(type: "int", nullable: false),
MontoCUPropuesto = table.Column<double>(type: "float", nullable: false),
Cantidad = table.Column<int>(type: "int", nullable: false),
ProductoId = table.Column<int>(type: "int", nullable: false),
IdProducto = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetallePresupuestos", x => new { x.Id, x.IdPresupuesto });
table.ForeignKey(
name: "FK_DetallePresupuestos_Presupuestos_IdPresupuesto",
column: x => x.IdPresupuesto,
principalTable: "Presupuestos",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetallePresupuestos_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Lotes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
IdRemito = table.Column<int>(type: "int", nullable: false),
Fecha = table.Column<DateTime>(type: "datetime2", nullable: false),
Habilitado = table.Column<bool>(type: "bit", nullable: false),
Cantidad = table.Column<int>(type: "int", nullable: false),
ProductoId = table.Column<int>(type: "int", nullable: false),
IdProducto = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Lotes", x => new { x.Id, x.IdRemito });
table.ForeignKey(
name: "FK_Lotes_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Lotes_Remitos_IdRemito",
column: x => x.IdRemito,
principalTable: "Remitos",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_DetalleOrdenDeCompras_IdOrdenDeCompra",
table: "DetalleOrdenDeCompras",
column: "IdOrdenDeCompra");
migrationBuilder.CreateIndex(
name: "IX_DetalleOrdenDeCompras_ProductoId",
table: "DetalleOrdenDeCompras",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_DetallePresupuestos_IdPresupuesto",
table: "DetallePresupuestos",
column: "IdPresupuesto");
migrationBuilder.CreateIndex(
name: "IX_DetallePresupuestos_ProductoId",
table: "DetallePresupuestos",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_DetallesFacturas_IdFactura",
table: "DetallesFacturas",
column: "IdFactura");
migrationBuilder.CreateIndex(
name: "IX_DetallesFacturas_IdProducto",
table: "DetallesFacturas",
column: "IdProducto");
migrationBuilder.CreateIndex(
name: "IX_Facturas_ClienteCuit",
table: "Facturas",
column: "ClienteCuit");
migrationBuilder.CreateIndex(
name: "IX_Lotes_IdRemito",
table: "Lotes",
column: "IdRemito");
migrationBuilder.CreateIndex(
name: "IX_Lotes_ProductoId",
table: "Lotes",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_OrdenDeCompras_ProveedorCuit",
table: "OrdenDeCompras",
column: "ProveedorCuit");
migrationBuilder.CreateIndex(
name: "IX_Presupuestos_ProveedorCuit",
table: "Presupuestos",
column: "ProveedorCuit");
migrationBuilder.CreateIndex(
name: "IX_ProductoCategoria_ProductoId",
table: "ProductoCategoria",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_ProductoProveedor_ProveedorId",
table: "ProductoProveedor",
column: "ProveedorId");
migrationBuilder.CreateIndex(
name: "IX_Remitos_ProveedorCuit",
table: "Remitos",
column: "ProveedorCuit");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DetalleOrdenDeCompras");
migrationBuilder.DropTable(
name: "DetallePresupuestos");
migrationBuilder.DropTable(
name: "DetallesFacturas");
migrationBuilder.DropTable(
name: "Lotes");
migrationBuilder.DropTable(
name: "ProductoCategoria");
migrationBuilder.DropTable(
name: "ProductoProveedor");
migrationBuilder.DropTable(
name: "OrdenDeCompras");
migrationBuilder.DropTable(
name: "Presupuestos");
migrationBuilder.DropTable(
name: "Facturas");
migrationBuilder.DropTable(
name: "Remitos");
migrationBuilder.DropTable(
name: "Categoria");
migrationBuilder.DropTable(
name: "Producto");
migrationBuilder.DropTable(
name: "Clientes");
migrationBuilder.DropTable(
name: "Proveedores");
}
}
}

View File

@@ -1,591 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240826213353_fixrelacionproductocategoria")]
partial class fixrelacionproductocategoria
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Cuit"));
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("IdProducto");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Cuit"));
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("IdProveedor")
.HasColumnType("int");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<int>("ProductoId")
.HasColumnType("int");
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.HasKey("ProductoId", "ProveedorId");
b.HasIndex("ProveedorId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("int");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("IdProducto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("Detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("Detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class fixrelacionproductocategoria : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -1,591 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240826222040_cambiadapkcompuesta")]
partial class cambiadapkcompuesta
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Cuit"));
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("IdProducto");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Cuit"));
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("IdProveedor")
.HasColumnType("int");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("ProveedorId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("int");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("IdProducto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("Detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("Detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,54 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class cambiadapkcompuesta : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_ProductoProveedor",
table: "ProductoProveedor");
migrationBuilder.DropIndex(
name: "IX_ProductoProveedor_ProveedorId",
table: "ProductoProveedor");
migrationBuilder.AddPrimaryKey(
name: "PK_ProductoProveedor",
table: "ProductoProveedor",
columns: new[] { "ProveedorId", "ProductoId" });
migrationBuilder.CreateIndex(
name: "IX_ProductoProveedor_ProductoId",
table: "ProductoProveedor",
column: "ProductoId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_ProductoProveedor",
table: "ProductoProveedor");
migrationBuilder.DropIndex(
name: "IX_ProductoProveedor_ProductoId",
table: "ProductoProveedor");
migrationBuilder.AddPrimaryKey(
name: "PK_ProductoProveedor",
table: "ProductoProveedor",
columns: new[] { "ProductoId", "ProveedorId" });
migrationBuilder.CreateIndex(
name: "IX_ProductoProveedor_ProveedorId",
table: "ProductoProveedor",
column: "ProveedorId");
}
}
}

View File

@@ -1,585 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240827025739_CuitNotGenerateValue")]
partial class CuitNotGenerateValue
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("IdProducto");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("IdProveedor")
.HasColumnType("int");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("ProveedorId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("int");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("IdProducto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("Detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,163 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class CuitNotGenerateValue : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Facturas_Clientes_ClienteCuit",
table: "Facturas");
migrationBuilder.DropForeignKey(
name: "FK_Remitos_Proveedores_ProveedorCuit",
table: "Remitos");
migrationBuilder.DropForeignKey(
name: "FK_ProductoProveedor_Proveedores_ProveedorId",
table: "ProductoProveedor");
migrationBuilder.DropForeignKey(
name: "FK_Presupuestos_Proveedores_ProveedorCuit",
table: "Presupuestos");
migrationBuilder.DropForeignKey(
name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit",
table: "OrdenDeCompras");
migrationBuilder.DropPrimaryKey(
name:"PK_Clientes",
table: "Clientes");
migrationBuilder.DropColumn(
name:"Cuit",
table: "Clientes");
migrationBuilder.DropPrimaryKey(
name: "PK_Proveedores",
table: "Proveedores");
migrationBuilder.DropColumn(
name:"Cuit",
table: "Proveedores");
migrationBuilder.AddColumn<long>(
name: "Cuit",
table: "Clientes",
nullable: false,
defaultValue: 0);
migrationBuilder.AddPrimaryKey(
name: "PK_Clientes",
table: "Clientes",
column: "Cuit");
migrationBuilder.AddColumn<long>(
name: "Cuit",
table: "Proveedores",
nullable: false,
defaultValue: 0);
migrationBuilder.AddPrimaryKey(
name: "PK_Proveedores",
table: "Proveedores",
column: "Cuit");
migrationBuilder.AddForeignKey(
name: "FK_Facturas_Clientes_ClienteCuit",
table: "Facturas",
column: "ClienteCuit",
principalTable: "Clientes",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Remitos_Proveedores_ProveedorCuit",
table: "Remitos",
column: "ProveedorCuit",
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProductoProveedor_Proveedores_ProveedorId",
table: "ProductoProveedor",
column: "ProveedorId",
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Presupuestos_Proveedores_ProveedorCuit",
table: "Presupuestos",
column: "ProveedorCuit",
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit",
table: "OrdenDeCompras",
column: "ProveedorCuit",
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "Cuit",
table: "Clientes");
migrationBuilder.DropColumn(
name: "Cuit",
table: "Clientes");
migrationBuilder.DropPrimaryKey(
name: "Cuit",
table: "Proveedores");
migrationBuilder.DropColumn(
name: "Cuit",
table: "Proveedores");
migrationBuilder.AddColumn<long>(
name: "Cuit",
table: "Proveedores",
type: "bigint",
nullable: false,
defaultValue: 0L)
.Annotation("SqlServer:Identity", "1, 1");
migrationBuilder.AddColumn<long>(
name: "Cuit",
table: "Clientes",
type: "bigint",
nullable: false,
defaultValue: 0L)
.Annotation("SqlServer:Identity", "1, 1");
migrationBuilder.AddPrimaryKey(
name: "Cuit",
table: "Proveedores",
column: "Cuit");
migrationBuilder.AddPrimaryKey(
name: "Cuit",
table: "Clientes",
column: "Cuit");
}
}
}

View File

@@ -1,576 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240907203054_funcatodo")]
partial class funcatodo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("ProductoId");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("IdProveedor")
.HasColumnType("int");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("ProveedorId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("int");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("Detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,95 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class funcatodo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DetallesFacturas_Producto_IdProducto",
table: "DetallesFacturas");
migrationBuilder.DropColumn(
name: "IdProducto",
table: "Lotes");
migrationBuilder.DropColumn(
name: "IdProducto",
table: "DetallePresupuestos");
migrationBuilder.DropColumn(
name: "IdProducto",
table: "DetalleOrdenDeCompras");
migrationBuilder.RenameColumn(
name: "IdProducto",
table: "DetallesFacturas",
newName: "ProductoId");
migrationBuilder.RenameIndex(
name: "IX_DetallesFacturas_IdProducto",
table: "DetallesFacturas",
newName: "IX_DetallesFacturas_ProductoId");
migrationBuilder.AddForeignKey(
name: "FK_DetallesFacturas_Producto_ProductoId",
table: "DetallesFacturas",
column: "ProductoId",
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DetallesFacturas_Producto_ProductoId",
table: "DetallesFacturas");
migrationBuilder.RenameColumn(
name: "ProductoId",
table: "DetallesFacturas",
newName: "IdProducto");
migrationBuilder.RenameIndex(
name: "IX_DetallesFacturas_ProductoId",
table: "DetallesFacturas",
newName: "IX_DetallesFacturas_IdProducto");
migrationBuilder.AddColumn<int>(
name: "IdProducto",
table: "Lotes",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "IdProducto",
table: "DetallePresupuestos",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "IdProducto",
table: "DetalleOrdenDeCompras",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_DetallesFacturas_Producto_IdProducto",
table: "DetallesFacturas",
column: "IdProducto",
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -1,573 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240908160636_eliminadocamporedundante")]
partial class eliminadocamporedundante
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("ProductoId");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("ProveedorId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("int");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,29 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class eliminadocamporedundante : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IdProveedor",
table: "Remitos");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "IdProveedor",
table: "Remitos",
type: "int",
nullable: false,
defaultValue: 0);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,556 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Modelo;
#nullable disable
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240908172708_Cambie_nombre_de_key2")]
partial class Cambie_nombre_de_key2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.8");
modelBuilder.Entity("Entidades.Categoria", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.HasColumnType("INTEGER");
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("TEXT");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("TEXT");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("INTEGER");
b.Property<int>("IdFactura")
.HasColumnType("INTEGER");
b.Property<int>("Cantidad")
.HasColumnType("INTEGER");
b.Property<int>("ProductoId")
.HasColumnType("INTEGER");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("ProductoId");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("INTEGER");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("INTEGER");
b.Property<int>("Cantidad")
.HasColumnType("INTEGER");
b.Property<int>("IdPresupuesto")
.HasColumnType("INTEGER");
b.Property<double>("MontoCU")
.HasColumnType("REAL");
b.Property<int>("ProductoId")
.HasColumnType("INTEGER");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("INTEGER");
b.Property<int>("IdPresupuesto")
.HasColumnType("INTEGER");
b.Property<int>("Cantidad")
.HasColumnType("INTEGER");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("REAL");
b.Property<int>("ProductoId")
.HasColumnType("INTEGER");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("ClienteCuit")
.HasColumnType("INTEGER");
b.Property<DateTime>("Fecha")
.HasColumnType("TEXT");
b.Property<long>("IdCliente")
.HasColumnType("INTEGER");
b.Property<double>("Total")
.HasColumnType("REAL");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("INTEGER");
b.Property<int>("IdRemito")
.HasColumnType("INTEGER");
b.Property<int>("Cantidad")
.HasColumnType("INTEGER");
b.Property<DateTime>("Fecha")
.HasColumnType("TEXT");
b.Property<bool>("Habilitado")
.HasColumnType("INTEGER");
b.Property<int>("ProductoId")
.HasColumnType("INTEGER");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<bool>("Entregado")
.HasColumnType("INTEGER");
b.Property<long>("IdProveedor")
.HasColumnType("INTEGER");
b.Property<long>("ProveedorCuit")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<bool>("Aceptado")
.HasColumnType("INTEGER");
b.Property<DateTime>("Fecha")
.HasColumnType("TEXT");
b.Property<bool>("Habilitado")
.HasColumnType("INTEGER");
b.Property<long>("IdProveedor")
.HasColumnType("INTEGER");
b.Property<long>("ProveedorCuit")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("TEXT");
b.Property<bool>("EsPerecedero")
.HasColumnType("INTEGER");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("TEXT");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.HasColumnType("INTEGER");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("TEXT");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("TEXT");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("TEXT");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("ProveedorCuit")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("INTEGER");
b.Property<int>("ProductoId")
.HasColumnType("INTEGER");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<long>("ProveedorId")
.HasColumnType("INTEGER");
b.Property<int>("ProductoId")
.HasColumnType("INTEGER");
b.HasKey("ProveedorId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("TEXT");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("INTEGER");
b.Property<int>("MesesHastaVencimiento")
.HasColumnType("INTEGER");
b.HasDiscriminator().HasValue("ProductoPercedero");
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.HasOne("Entidades.Factura", null)
.WithMany("Detalles")
.HasForeignKey("IdFactura")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.HasOne("Entidades.OrdenDeCompra", null)
.WithMany("detalles")
.HasForeignKey("IdOrdenDeCompra")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.HasOne("Entidades.Presupuesto", null)
.WithMany("detalles")
.HasForeignKey("IdPresupuesto")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.HasOne("Entidades.Cliente", "Cliente")
.WithMany()
.HasForeignKey("ClienteCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cliente");
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.HasOne("Entidades.Remito", null)
.WithMany("Lotes")
.HasForeignKey("IdRemito")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", "Producto")
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Producto");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.HasOne("Entidades.Proveedor", "Proveedor")
.WithMany()
.HasForeignKey("ProveedorCuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Proveedor");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.HasOne("Entidades.Categoria", null)
.WithMany()
.HasForeignKey("CategoriaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.HasOne("Entidades.Producto", null)
.WithMany()
.HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entidades.Proveedor", null)
.WithMany()
.HasForeignKey("ProveedorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Navigation("Detalles");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Navigation("detalles");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Navigation("detalles");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Navigation("Lotes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,437 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class Cambie_nombre_de_key2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Categoria",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Descripcion = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Categoria", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Clientes",
columns: table => new
{
Cuit = table.Column<long>(type: "INTEGER", nullable: false),
Nombre = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false),
Apellido = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false),
Direccion = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Correo = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
Habilitado = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Clientes", x => x.Cuit);
});
migrationBuilder.CreateTable(
name: "Producto",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nombre = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false),
Precio = table.Column<double>(type: "float", nullable: false),
Habilitado = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: true),
EsPerecedero = table.Column<bool>(type: "INTEGER", nullable: false),
Discriminator = table.Column<string>(type: "TEXT", maxLength: 21, nullable: false),
TipoDeEnvase = table.Column<string>(type: "TEXT", nullable: true),
MesesHastaConsumoPreferente = table.Column<int>(type: "INTEGER", nullable: true),
MesesHastaVencimiento = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Producto", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Proveedores",
columns: table => new
{
Cuit = table.Column<long>(type: "INTEGER", nullable: false),
Nombre = table.Column<string>(type: "TEXT", maxLength: 30, nullable: false),
RazonSocial = table.Column<string>(type: "TEXT", maxLength: 60, nullable: false),
Direccion = table.Column<string>(type: "TEXT", maxLength: 60, nullable: false),
Habilitado = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Proveedores", x => x.Cuit);
});
migrationBuilder.CreateTable(
name: "Facturas",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Total = table.Column<double>(type: "REAL", nullable: false),
Fecha = table.Column<DateTime>(type: "TEXT", nullable: false),
IdCliente = table.Column<long>(type: "INTEGER", nullable: false),
ClienteCuit = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Facturas", x => x.Id);
table.ForeignKey(
name: "FK_Facturas_Clientes_ClienteCuit",
column: x => x.ClienteCuit,
principalTable: "Clientes",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductoCategoria",
columns: table => new
{
CategoriaId = table.Column<int>(type: "INTEGER", nullable: false),
ProductoId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductoCategoria", x => new { x.CategoriaId, x.ProductoId });
table.ForeignKey(
name: "FK_ProductoCategoria_Categoria_CategoriaId",
column: x => x.CategoriaId,
principalTable: "Categoria",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductoCategoria_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrdenDeCompras",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ProveedorCuit = table.Column<long>(type: "INTEGER", nullable: false),
IdProveedor = table.Column<long>(type: "INTEGER", nullable: false),
Entregado = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrdenDeCompras", x => x.Id);
table.ForeignKey(
name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit",
column: x => x.ProveedorCuit,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Presupuestos",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Fecha = table.Column<DateTime>(type: "TEXT", nullable: false),
Habilitado = table.Column<bool>(type: "INTEGER", nullable: false),
Aceptado = table.Column<bool>(type: "INTEGER", nullable: false),
ProveedorCuit = table.Column<long>(type: "INTEGER", nullable: false),
IdProveedor = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Presupuestos", x => x.Id);
table.ForeignKey(
name: "FK_Presupuestos_Proveedores_ProveedorCuit",
column: x => x.ProveedorCuit,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductoProveedor",
columns: table => new
{
ProveedorId = table.Column<long>(type: "INTEGER", nullable: false),
ProductoId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductoProveedor", x => new { x.ProveedorId, x.ProductoId });
table.ForeignKey(
name: "FK_ProductoProveedor_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductoProveedor_Proveedores_ProveedorId",
column: x => x.ProveedorId,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Remitos",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ProveedorCuit = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Remitos", x => x.Id);
table.ForeignKey(
name: "FK_Remitos_Proveedores_ProveedorCuit",
column: x => x.ProveedorCuit,
principalTable: "Proveedores",
principalColumn: "Cuit",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetallesFacturas",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false),
IdFactura = table.Column<int>(type: "INTEGER", nullable: false),
Cantidad = table.Column<int>(type: "INTEGER", nullable: false),
ProductoId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetallesFacturas", x => new { x.Id, x.IdFactura });
table.ForeignKey(
name: "FK_DetallesFacturas_Facturas_IdFactura",
column: x => x.IdFactura,
principalTable: "Facturas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetallesFacturas_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetalleOrdenDeCompras",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false),
IdOrdenDeCompra = table.Column<int>(type: "INTEGER", nullable: false),
MontoCU = table.Column<double>(type: "REAL", nullable: false),
IdPresupuesto = table.Column<int>(type: "INTEGER", nullable: false),
Cantidad = table.Column<int>(type: "INTEGER", nullable: false),
ProductoId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetalleOrdenDeCompras", x => new { x.Id, x.IdOrdenDeCompra });
table.ForeignKey(
name: "FK_DetalleOrdenDeCompras_OrdenDeCompras_IdOrdenDeCompra",
column: x => x.IdOrdenDeCompra,
principalTable: "OrdenDeCompras",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetalleOrdenDeCompras_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetallePresupuestos",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false),
IdPresupuesto = table.Column<int>(type: "INTEGER", nullable: false),
MontoCUPropuesto = table.Column<double>(type: "REAL", nullable: false),
Cantidad = table.Column<int>(type: "INTEGER", nullable: false),
ProductoId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetallePresupuestos", x => new { x.Id, x.IdPresupuesto });
table.ForeignKey(
name: "FK_DetallePresupuestos_Presupuestos_IdPresupuesto",
column: x => x.IdPresupuesto,
principalTable: "Presupuestos",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetallePresupuestos_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Lotes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false),
IdRemito = table.Column<int>(type: "INTEGER", nullable: false),
Fecha = table.Column<DateTime>(type: "TEXT", nullable: false),
Habilitado = table.Column<bool>(type: "INTEGER", nullable: false),
Cantidad = table.Column<int>(type: "INTEGER", nullable: false),
ProductoId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Lotes", x => new { x.Id, x.IdRemito });
table.ForeignKey(
name: "FK_Lotes_Producto_ProductoId",
column: x => x.ProductoId,
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Lotes_Remitos_IdRemito",
column: x => x.IdRemito,
principalTable: "Remitos",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_DetalleOrdenDeCompras_IdOrdenDeCompra",
table: "DetalleOrdenDeCompras",
column: "IdOrdenDeCompra");
migrationBuilder.CreateIndex(
name: "IX_DetalleOrdenDeCompras_ProductoId",
table: "DetalleOrdenDeCompras",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_DetallePresupuestos_IdPresupuesto",
table: "DetallePresupuestos",
column: "IdPresupuesto");
migrationBuilder.CreateIndex(
name: "IX_DetallePresupuestos_ProductoId",
table: "DetallePresupuestos",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_DetallesFacturas_IdFactura",
table: "DetallesFacturas",
column: "IdFactura");
migrationBuilder.CreateIndex(
name: "IX_DetallesFacturas_ProductoId",
table: "DetallesFacturas",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_Facturas_ClienteCuit",
table: "Facturas",
column: "ClienteCuit");
migrationBuilder.CreateIndex(
name: "IX_Lotes_IdRemito",
table: "Lotes",
column: "IdRemito");
migrationBuilder.CreateIndex(
name: "IX_Lotes_ProductoId",
table: "Lotes",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_OrdenDeCompras_ProveedorCuit",
table: "OrdenDeCompras",
column: "ProveedorCuit");
migrationBuilder.CreateIndex(
name: "IX_Presupuestos_ProveedorCuit",
table: "Presupuestos",
column: "ProveedorCuit");
migrationBuilder.CreateIndex(
name: "IX_ProductoCategoria_ProductoId",
table: "ProductoCategoria",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_ProductoProveedor_ProductoId",
table: "ProductoProveedor",
column: "ProductoId");
migrationBuilder.CreateIndex(
name: "IX_Remitos_ProveedorCuit",
table: "Remitos",
column: "ProveedorCuit");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DetalleOrdenDeCompras");
migrationBuilder.DropTable(
name: "DetallePresupuestos");
migrationBuilder.DropTable(
name: "DetallesFacturas");
migrationBuilder.DropTable(
name: "Lotes");
migrationBuilder.DropTable(
name: "ProductoCategoria");
migrationBuilder.DropTable(
name: "ProductoProveedor");
migrationBuilder.DropTable(
name: "OrdenDeCompras");
migrationBuilder.DropTable(
name: "Presupuestos");
migrationBuilder.DropTable(
name: "Facturas");
migrationBuilder.DropTable(
name: "Remitos");
migrationBuilder.DropTable(
name: "Categoria");
migrationBuilder.DropTable(
name: "Producto");
migrationBuilder.DropTable(
name: "Clientes");
migrationBuilder.DropTable(
name: "Proveedores");
}
}
}

View File

@@ -11,8 +11,8 @@ using Modelo;
namespace Modelo.Migrations
{
[DbContext(typeof(Context))]
[Migration("20240908162248_mepaseasqlite")]
partial class mepaseasqlite
[Migration("20240930233807_initial-migration")]
partial class initialmigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class mepaseasqlite : Migration
public partial class initialmigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@@ -15,17 +15,22 @@ namespace Modelo
{
return context.Facturas
.AsNoTracking()
.Include(x=>x.Detalles)
.Include(x=>x.Cliente)
.ToList();
}
public Factura ObtenerPorId(int Tid)
{
Factura fac = context.Facturas.First(x => x.Id == Tid);
return fac ?? new Factura();
}
public override void Add(Factura t)
{
t.Cliente = context.Clientes.FirstOrDefault(x => x.Cuit == t.Cliente.Cuit);
foreach (var detalle in t.Detalles)
{
detalle.Producto = (detalle.Producto.EsPerecedero) ?
context.ProductoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id) :
context.ProductoNoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id) ;
}
context.Facturas.Add(t);
}
@@ -41,6 +46,13 @@ namespace Modelo
context.Facturas.Update(t);
}
public Factura ObtenerPorId(Factura fac)
{
var factura = context.Facturas
.Include(x=>x.Detalles)
.ThenInclude(x=>x.Producto)
.FirstOrDefault(x => x.Id == fac.Id);
return factura;
}
}
}

View File

@@ -53,37 +53,45 @@ namespace Modelo
context.Lotes.Update(t);
}
public bool DisminuirStock(DetalleFactura detalleFactura)
public bool DisminuirStock(Factura fac)
{
var detalle = context.DetalleFacturas.First(x => x.Id == detalleFactura.Id);
bool ret = false; int cantidad = detalle.Cantidad;
while (cantidad > 0)
bool ret = false;
foreach (var detalle in fac.Detalles)
{
var elementoAdisminuir = context.Lotes.Where(x => x.Habilitado == true)
.First(x => x.Producto.Id == detalle.Producto.Id);
cantidad -= elementoAdisminuir.Cantidad;
if (cantidad > 0)
int cantidad = detalle.Cantidad;
while (cantidad > 0)
{
elementoAdisminuir.Cantidad = 0;
elementoAdisminuir.Habilitado = false;
}
else if (cantidad == 0)
{
elementoAdisminuir.Cantidad = 0;
elementoAdisminuir.Habilitado = false;
ret = true;
}
else
{
elementoAdisminuir.Cantidad = -cantidad;
ret = true;
}
context.Lotes.Update(elementoAdisminuir);
var elementoAdisminuir = context.Lotes.Where(x => x.Habilitado == true)
.FirstOrDefault(x => x.Producto.Id == detalle.Producto.Id);
if (elementoAdisminuir.Cantidad == 0) {
elementoAdisminuir.Habilitado = false;
context.SaveChanges();
}
cantidad -= elementoAdisminuir.Cantidad;
if (cantidad > 0)
{
elementoAdisminuir.Cantidad = 0;
elementoAdisminuir.Habilitado = false;
}
else if (cantidad == 0)
{
elementoAdisminuir.Cantidad = 0;
elementoAdisminuir.Habilitado = false;
ret = true;
context.Lotes.Update(elementoAdisminuir);
}
else
{
elementoAdisminuir.Cantidad = -cantidad;
ret = true;
context.Lotes.Update(elementoAdisminuir);
}
}
}
context.DetalleFacturas.Update(detalle);
//context.DetalleFacturas.Update(detalleFactura);
return ret;
}

View File

@@ -30,37 +30,25 @@ namespace Vista
dgvProductos.DataSource = null;
dgvProductos.DataSource = ControladoraFacturas.Instance.ListarProductos();
dgvDetalles.AutoGenerateColumns = false;
dgvClientes.DataSource = null;
dgvClientes.DataSource = ControladoraFacturas.Instance.ListarClientes();
// Definir las columnas manualmente
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
foreach (DataGridViewColumn column in dgvDetalles.Columns)
{
DataPropertyName = "Id", // Usa la propiedad NombreProducto
HeaderText = "Id",
Name = "Id"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
column.Visible = column.Name == "Id" || column.Name == "Producto" || column.Name == "Cantidad"
|| column.Name == "PrecioUnitario" || column.Name == "Subtotal";
}
foreach (DataGridViewColumn column in dgvClientes.Columns)
{
DataPropertyName = "Producto", // Usa la propiedad NombreProducto
HeaderText = "Producto",
Name = "Producto"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
column.Visible = column.Name == "Cuit" || column.Name == "NombreCompleto" || column.Name == "Correo";
}
foreach (DataGridViewColumn column in dgvProductos.Columns)
{
DataPropertyName = "CantidadDeProductos",
HeaderText = "Cantidad",
Name = "CantidadDeProductos"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
{
DataPropertyName = "PrecioUnitario",
HeaderText = "PrecioUnitario"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
{
DataPropertyName = "Subtotal",
HeaderText = "Subtotal"
});
column.Visible = column.Name == "Id" || column.Name == "Nombre" || column.Name == "Precio";
}
}
@@ -100,7 +88,7 @@ namespace Vista
string devolucion = "";
if (string.IsNullOrEmpty(numid.Text)) devolucion += "El ID no puede ser nulo o vacío\n";
//if (cmbCliente.SelectedIndex == -1) devolucion += "Debe seleccionar un cliente\n";
//if (dgvClientes.Enabled == true) devolucion += "Debe seleccionar un cliente\n";
if (devolucion == "")
{
@@ -120,8 +108,7 @@ namespace Vista
{
factura.Total = Convert.ToDouble(numtotal.Value);
factura.Fecha = datepick.Value;
factura.Id = Convert.ToInt32(numid.Value);
factura.Cliente = new Cliente { Cuit = (long)dgvClientes.SelectedRows[0].Cells["Cuit"].Value };
string mensaje = ControladoraFacturas.Instance.Añadir(factura);
MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -131,7 +118,10 @@ namespace Vista
private void btnAddDetalle_Click(object sender, EventArgs e)
{
// Validar los datos antes de crear el detalle
// No quiero que cambien de cliente una vez que ya empezaron a armar la factura
dgvClientes.Enabled = false;
if (ValidarDatosdetalle()) return;
if (dgvProductos.SelectedRows.Count > 0)
{
@@ -147,9 +137,8 @@ namespace Vista
factura.AñadirDetalle(new DetalleFactura
{
Id = int.Parse(detalleid++.ToString()),
Cantidad = (int)numCantidad.Value,
IdFactura = factura.Id,
Producto = ControladoraProductos.Instance.Listar().First(x => x.Id == producto.Id),
});
ActualizarGrillaDetalles();

View File

@@ -10,73 +10,48 @@ namespace Vista
public FrmFacturas()
{
InitializeComponent();
ConfigurarDataGridViewDetalle();
ActualizarGrilla();
ActualizarGrillas();
}
private void ActualizarGrilla()
private void ActualizarGrillas()
{
dgvFacturas.DataSource = null;
dgvFacturas.DataSource = ControladoraFacturas.Instance.Listar();
foreach (DataGridViewColumn column in dgvFacturas.Columns)
{
column.Visible = column.Name == "Total" || column.Name == "Fecha"
|| column.Name == "NombreCliente" || column.Name == "Cuit";
}
}
private void BtnAdd_Click(object sender, EventArgs e)
{
var form = new FrmFactura();
form.ShowDialog();
ActualizarGrilla();
ActualizarGrillas();
}
private void ConfigurarDataGridViewDetalle()
{
dgvDetalles.AutoGenerateColumns = false;
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
{
DataPropertyName = "Producto",
HeaderText = "Producto",
Name = "Producto"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
{
DataPropertyName = "Cantidad",
HeaderText = "Cantidad",
Name = "Cantidad"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
{
DataPropertyName = "PrecioUnitario",
HeaderText = "PrecioUnitario",
Name = "PrecioUnitario"
});
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
{
DataPropertyName = "Subtotal",
HeaderText = "Subtotal",
Name = "Subtotal"
});
}
private void ActualizarGrillaDetalles(ReadOnlyCollection<DetalleFactura> detalles)
private void ActualizarGrillaDetalles(Factura fac)
{
dgvDetalles.DataSource = null;
if (detalles.Any())
{
var loteDatos = detalles.Select(detalle => new
{
Producto = detalle.Producto.Nombre,
Cantidad = detalle.Cantidad,
Subtotal = detalle.Subtotal,
PrecioUnitario = detalle.Producto.Precio,
}).ToList();
dgvDetalles.DataSource = fac.Detalles;
dgvDetalles.DataSource = loteDatos;
foreach (DataGridViewColumn column in dgvDetalles.Columns)
{
column.Visible = column.Name == "Cantidad" || column.Name == "NombreProducto"
|| column.Name == "PrecioUnitario" || column.Name == "Subtotal";
}
}
private void dgvFacturas_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
if (dgvFacturas.SelectedRows.Count > 0 )
{
var selectedFactura = (Factura)dgvFacturas.Rows[e.RowIndex].DataBoundItem;
var detalles = ControladoraFacturas.Instance.ListarDetallesFactura(selectedFactura);
ActualizarGrillaDetalles(detalles);
var factura = ControladoraFacturas.Instance.ObtenerPorId((Factura)dgvFacturas.SelectedRows[0].DataBoundItem);
ActualizarGrillaDetalles(factura);
}
}

View File

@@ -80,6 +80,7 @@
//
numStock.Enabled = false;
numStock.Location = new Point(317, 269);
numStock.Maximum = new decimal(new int[] { 99999999, 0, 0, 0 });
numStock.Name = "numStock";
numStock.Size = new Size(120, 23);
numStock.TabIndex = 13;