From 3f526d09d622e47e20877fe974ea945e0a3c9a6f Mon Sep 17 00:00:00 2001 From: fede Date: Wed, 14 Aug 2024 00:26:42 -0300 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20Context=20de=20entity=20y=20corr?= =?UTF-8?q?ejidos=20algunos=20temas=20de=20las=20entidades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entidades/DetalleFactura.cs | 12 +++++++- Entidades/DetalleOrdenDeCompra.cs | 7 ++++- Entidades/DetallePresupuesto.cs | 5 +++- Entidades/Lote.cs | 4 +++ Entidades/OrdenDeCompra.cs | 3 ++ Entidades/Presupuesto.cs | 4 ++- Entidades/Producto.cs | 11 +------ Entidades/Remito.cs | 4 ++- Informes/Informes.csproj | 4 +++ .../obj/Debug/net8.0/Informes.AssemblyInfo.cs | 9 +++--- Modelo/Context.cs | 17 +++++++++++ Modelo/IRepositorio.cs | 4 +-- .../20240812181354_Initial.Designer.cs | 29 +++++++++++++++++++ Modelo/Migrations/20240812181354_Initial.cs | 22 ++++++++++++++ Modelo/Migrations/ContextModelSnapshot.cs | 26 +++++++++++++++++ .../Modelo.csproj.EntityFrameworkCore.targets | 28 ++++++++++++++++++ Modelo/RepositorioCategoria.cs | 4 +-- Vista/obj/Vista.csproj.nuget.g.props | 13 ++++----- Vista/obj/Vista.csproj.nuget.g.targets | 4 +-- testing/GlobalUsings.cs | 1 + testing/UnitTest1.cs | 20 +++++++++++++ .../obj/Debug/net8.0/testing.AssemblyInfo.cs | 22 ++++++++++++++ ....GeneratedMSBuildEditorConfig.editorconfig | 13 +++++++++ .../Debug/net8.0/testing.GlobalUsings.g.cs | 8 +++++ testing/obj/testing.csproj.nuget.g.props | 26 +++++++++++++++++ testing/obj/testing.csproj.nuget.g.targets | 11 +++++++ testing/testing.csproj | 24 +++++++++++++++ 27 files changed, 302 insertions(+), 33 deletions(-) create mode 100644 Modelo/Context.cs create mode 100644 Modelo/Migrations/20240812181354_Initial.Designer.cs create mode 100644 Modelo/Migrations/20240812181354_Initial.cs create mode 100644 Modelo/Migrations/ContextModelSnapshot.cs create mode 100644 Modelo/Modelo/obj/Modelo.csproj.EntityFrameworkCore.targets create mode 100644 testing/GlobalUsings.cs create mode 100644 testing/UnitTest1.cs create mode 100644 testing/obj/Debug/net8.0/testing.AssemblyInfo.cs create mode 100644 testing/obj/Debug/net8.0/testing.GeneratedMSBuildEditorConfig.editorconfig create mode 100644 testing/obj/Debug/net8.0/testing.GlobalUsings.g.cs create mode 100644 testing/obj/testing.csproj.nuget.g.props create mode 100644 testing/obj/testing.csproj.nuget.g.targets create mode 100644 testing/testing.csproj diff --git a/Entidades/DetalleFactura.cs b/Entidades/DetalleFactura.cs index d0092bc..15d68d6 100644 --- a/Entidades/DetalleFactura.cs +++ b/Entidades/DetalleFactura.cs @@ -1,9 +1,19 @@  +using System.ComponentModel.DataAnnotations.Schema; + namespace Entidades { public class DetalleFactura: Detalle { public int IdFactura { get; set; } - public double Subtotal { get; set; } + + [NotMapped] + public double Subtotal + { + get + { + return Producto.Precio * Cantidad; + } + } } } diff --git a/Entidades/DetalleOrdenDeCompra.cs b/Entidades/DetalleOrdenDeCompra.cs index 20c7591..7249f2e 100644 --- a/Entidades/DetalleOrdenDeCompra.cs +++ b/Entidades/DetalleOrdenDeCompra.cs @@ -1,4 +1,6 @@  +using System.ComponentModel.DataAnnotations.Schema; + namespace Entidades { public class DetalleOrdenDeCompra: Detalle @@ -6,7 +8,8 @@ namespace Entidades public int IdOrdenDeCompra { get; set; } public Presupuesto presupuesto { get; set; } public double MontoCU { get; set; } - + + [NotMapped] public int IdPresupuesto { get @@ -14,6 +17,7 @@ namespace Entidades return presupuesto.Id; } } + [NotMapped] public string NombreProducto { get @@ -21,6 +25,7 @@ namespace Entidades return Producto.Nombre; } } + [NotMapped] public double SubTotal { get diff --git a/Entidades/DetallePresupuesto.cs b/Entidades/DetallePresupuesto.cs index f2ffc8b..082b0b3 100644 --- a/Entidades/DetallePresupuesto.cs +++ b/Entidades/DetallePresupuesto.cs @@ -1,5 +1,6 @@  using System.ComponentModel; +using System.ComponentModel.DataAnnotations.Schema; namespace Entidades { @@ -8,13 +9,15 @@ namespace Entidades public int IdPresupuesto { get; set; } public double MontoCUPropuesto { get; set; } + + [NotMapped] public string NombreDelProducto { get { return Producto.Nombre; } } - + [NotMapped] public double Subtotal { get { diff --git a/Entidades/Lote.cs b/Entidades/Lote.cs index 697ca9c..e65547c 100644 --- a/Entidades/Lote.cs +++ b/Entidades/Lote.cs @@ -1,4 +1,6 @@  +using System.ComponentModel.DataAnnotations.Schema; + namespace Entidades { public class Lote: Detalle @@ -6,6 +8,8 @@ namespace Entidades public int IdRemito { get; set; } public DateTime Fecha { get; set; } public bool Habilitado { get; set; } + + [NotMapped] public string NombreProducto { get diff --git a/Entidades/OrdenDeCompra.cs b/Entidades/OrdenDeCompra.cs index 67232de..cdd4f0d 100644 --- a/Entidades/OrdenDeCompra.cs +++ b/Entidades/OrdenDeCompra.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; using System.Security.Cryptography.X509Certificates; namespace Entidades @@ -27,6 +28,7 @@ namespace Entidades return detalles.AsReadOnly(); } + [NotMapped] public double MontoTotal { get @@ -34,6 +36,7 @@ namespace Entidades return detalles.Sum(x => x.SubTotal); } } + [NotMapped] public string NombreProveedor { get diff --git a/Entidades/Presupuesto.cs b/Entidades/Presupuesto.cs index f77c4f8..9e4cc51 100644 --- a/Entidades/Presupuesto.cs +++ b/Entidades/Presupuesto.cs @@ -1,6 +1,7 @@  using System.Collections.ObjectModel; + using System.ComponentModel.DataAnnotations.Schema; -namespace Entidades + namespace Entidades { public class Presupuesto { @@ -10,6 +11,7 @@ namespace Entidades public bool Aceptado { get; set; } public Proveedor Proveedor { get; set; } + [NotMapped] public string ProveedorNombre { get diff --git a/Entidades/Producto.cs b/Entidades/Producto.cs index 2f1e35c..9fb009d 100644 --- a/Entidades/Producto.cs +++ b/Entidades/Producto.cs @@ -1,5 +1,6 @@ using System.Collections.ObjectModel; using System.ComponentModel; +using System.ComponentModel.DataAnnotations.Schema; namespace Entidades { @@ -10,16 +11,6 @@ namespace Entidades public double Precio { get; set; } public bool Habilitado { get; set; } public bool EsPerecedero { get; set; } - [Browsable(false)] - public Categoria Categoria { get; set; } - - public string Cartegoria_ - { - get - { - return Categoria.Descripcion; - } - } private List proveedores = new List(); diff --git a/Entidades/Remito.cs b/Entidades/Remito.cs index e74a9ae..0ec9f85 100644 --- a/Entidades/Remito.cs +++ b/Entidades/Remito.cs @@ -1,6 +1,7 @@  using System.Collections.ObjectModel; + using System.ComponentModel.DataAnnotations.Schema; -namespace Entidades + namespace Entidades { public class Remito { @@ -23,6 +24,7 @@ namespace Entidades throw; } } + [NotMapped] public string NombreProveedor { get diff --git a/Informes/Informes.csproj b/Informes/Informes.csproj index e0ed412..76b1725 100644 --- a/Informes/Informes.csproj +++ b/Informes/Informes.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs b/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs index 16ad878..8e0b0bb 100644 --- a/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs +++ b/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // -// Este código fue generado por una herramienta. -// Versión de runtime:4.0.30319.42000 +// This code was generated by a tool. // -// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si -// se vuelve a generar el código. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -14,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Informes")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b7177439ef104717a1ee2d2c0f75a07f1f704f66")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1d23af8e9376b41ff6da577baf667654769a1236")] [assembly: System.Reflection.AssemblyProductAttribute("Informes")] [assembly: System.Reflection.AssemblyTitleAttribute("Informes")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Modelo/Context.cs b/Modelo/Context.cs new file mode 100644 index 0000000..95e35d1 --- /dev/null +++ b/Modelo/Context.cs @@ -0,0 +1,17 @@ +using Entidades; +using Microsoft.EntityFrameworkCore; + +namespace Modelo; + +public class Context : Microsoft.EntityFrameworkCore.DbContext +{ + public DbSet Categorias { get; set; } + public DbSet Clientes { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { // Esto de poner credenciales sueltas está mal + optionsBuilder.UseSqlServer(@"Server=fedesrv.ddns.net,1433;Database=ControlStockDAS;User Id=ProyectoDas;Password=A?5?~*=Gux'}JT0me,z5Cf^f(s'-gy[G#-jt%b&uHe+/,$Gl>qkXl-c[@&e(\.V?[3)\w|aMH+^67x;Trusted_Connection=False;Encrypt=False;Connection Timeout=5;"); + } + +} + diff --git a/Modelo/IRepositorio.cs b/Modelo/IRepositorio.cs index 53a28ab..4aef744 100644 --- a/Modelo/IRepositorio.cs +++ b/Modelo/IRepositorio.cs @@ -1,12 +1,12 @@ using System; using System.Collections.ObjectModel; +using System.Diagnostics.Contracts; namespace Modelo { public abstract class IRepositorio { - // Lista el contenido del repositorio - public IEnumerable Listar(); + public IEnumerable Listar(); public abstract T ObtenerPorId(int Tid); public abstract void Add(T t); public abstract void Del(T t); diff --git a/Modelo/Migrations/20240812181354_Initial.Designer.cs b/Modelo/Migrations/20240812181354_Initial.Designer.cs new file mode 100644 index 0000000..1f55a0c --- /dev/null +++ b/Modelo/Migrations/20240812181354_Initial.Designer.cs @@ -0,0 +1,29 @@ +// +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 + { + /// + 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 + } + } +} diff --git a/Modelo/Migrations/20240812181354_Initial.cs b/Modelo/Migrations/20240812181354_Initial.cs new file mode 100644 index 0000000..40bd803 --- /dev/null +++ b/Modelo/Migrations/20240812181354_Initial.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Modelo/Migrations/ContextModelSnapshot.cs b/Modelo/Migrations/ContextModelSnapshot.cs new file mode 100644 index 0000000..522241d --- /dev/null +++ b/Modelo/Migrations/ContextModelSnapshot.cs @@ -0,0 +1,26 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + partial class ContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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 + } + } +} diff --git a/Modelo/Modelo/obj/Modelo.csproj.EntityFrameworkCore.targets b/Modelo/Modelo/obj/Modelo.csproj.EntityFrameworkCore.targets new file mode 100644 index 0000000..6b67a59 --- /dev/null +++ b/Modelo/Modelo/obj/Modelo.csproj.EntityFrameworkCore.targets @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Modelo/RepositorioCategoria.cs b/Modelo/RepositorioCategoria.cs index 4ccd9b4..382e01b 100644 --- a/Modelo/RepositorioCategoria.cs +++ b/Modelo/RepositorioCategoria.cs @@ -1,4 +1,5 @@ -using Entidades; +using System.Transactions; +using Entidades; using Microsoft.EntityFrameworkCore; namespace Modelo @@ -6,7 +7,6 @@ namespace Modelo public sealed class RepositorioCategoria : IRepositorio { private Context context; - public RepositorioCategoria(Context context) { this.context = context; diff --git a/Vista/obj/Vista.csproj.nuget.g.props b/Vista/obj/Vista.csproj.nuget.g.props index f47043e..69e043f 100644 --- a/Vista/obj/Vista.csproj.nuget.g.props +++ b/Vista/obj/Vista.csproj.nuget.g.props @@ -4,19 +4,18 @@ True NuGet $(MSBuildThisFileDirectory)project.assets.json - $(UserProfile)\.nuget\packages\ - C:\Users\Navegador\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages + /home/fede/.nuget/packages/ + /home/fede/.nuget/packages/ PackageReference - 6.10.1 + 6.9.1 - - + - + - C:\Users\Navegador\.nuget\packages\microsoft.web.webview2\1.0.864.35 + /home/fede/.nuget/packages/microsoft.web.webview2/1.0.864.35 \ No newline at end of file diff --git a/Vista/obj/Vista.csproj.nuget.g.targets b/Vista/obj/Vista.csproj.nuget.g.targets index d3426da..7cb6e85 100644 --- a/Vista/obj/Vista.csproj.nuget.g.targets +++ b/Vista/obj/Vista.csproj.nuget.g.targets @@ -1,7 +1,7 @@  - - + + \ No newline at end of file diff --git a/testing/GlobalUsings.cs b/testing/GlobalUsings.cs new file mode 100644 index 0000000..cefced4 --- /dev/null +++ b/testing/GlobalUsings.cs @@ -0,0 +1 @@ +global using NUnit.Framework; \ No newline at end of file diff --git a/testing/UnitTest1.cs b/testing/UnitTest1.cs new file mode 100644 index 0000000..aa11257 --- /dev/null +++ b/testing/UnitTest1.cs @@ -0,0 +1,20 @@ +using Modelo; + +namespace testing; + +public class Tests +{ + [SetUp] + public void Setup() + { + } + + [Test] + public void TestConeccion() + { + Context c = new(); + bool connect = c.Database.CanConnect(); + + Assert.True(connect); + } +} \ No newline at end of file diff --git a/testing/obj/Debug/net8.0/testing.AssemblyInfo.cs b/testing/obj/Debug/net8.0/testing.AssemblyInfo.cs new file mode 100644 index 0000000..9b6519f --- /dev/null +++ b/testing/obj/Debug/net8.0/testing.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("testing")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1d23af8e9376b41ff6da577baf667654769a1236")] +[assembly: System.Reflection.AssemblyProductAttribute("testing")] +[assembly: System.Reflection.AssemblyTitleAttribute("testing")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generado por la clase WriteCodeFragment de MSBuild. + diff --git a/testing/obj/Debug/net8.0/testing.GeneratedMSBuildEditorConfig.editorconfig b/testing/obj/Debug/net8.0/testing.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..eaff690 --- /dev/null +++ b/testing/obj/Debug/net8.0/testing.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,13 @@ +is_global = true +build_property.TargetFramework = net8.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = testing +build_property.ProjectDir = /home/fede/proyectos/Final_OOP/testing/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/testing/obj/Debug/net8.0/testing.GlobalUsings.g.cs b/testing/obj/Debug/net8.0/testing.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/testing/obj/Debug/net8.0/testing.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/testing/obj/testing.csproj.nuget.g.props b/testing/obj/testing.csproj.nuget.g.props new file mode 100644 index 0000000..644e102 --- /dev/null +++ b/testing/obj/testing.csproj.nuget.g.props @@ -0,0 +1,26 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /home/fede/.nuget/packages/ + /home/fede/.nuget/packages/ + PackageReference + 6.9.1 + + + + + + + + + + + + + + /home/fede/.nuget/packages/nunit.analyzers/3.6.1 + + \ No newline at end of file diff --git a/testing/obj/testing.csproj.nuget.g.targets b/testing/obj/testing.csproj.nuget.g.targets new file mode 100644 index 0000000..248ae0c --- /dev/null +++ b/testing/obj/testing.csproj.nuget.g.targets @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/testing/testing.csproj b/testing/testing.csproj new file mode 100644 index 0000000..f9f9920 --- /dev/null +++ b/testing/testing.csproj @@ -0,0 +1,24 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + +