diff --git a/MP.Data/DatabaseModels/AnagMagModel.cs b/MP.Data/DatabaseModels/AnagMagModel.cs
new file mode 100644
index 00000000..2be9fd43
--- /dev/null
+++ b/MP.Data/DatabaseModels/AnagMagModel.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+#nullable disable
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace MP.Data.DatabaseModels
+{
+ [Table("AnagMagazzini")]
+ public partial class AnagMagModel
+ {
+ #region Public Properties
+
+
+ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int MagID { get; set; }
+ public string CodMag { get; set; } = "";
+ public string CodCS { get; set; } = "";
+ public string DescMag { get; set; } = "";
+ public bool Nascosto { get; set; } = false;
+
+ #endregion Public Properties
+ }
+}
\ No newline at end of file
diff --git a/MP.Data/DatabaseModels/InventorySessionModel.cs b/MP.Data/DatabaseModels/InventorySessionModel.cs
index cdc1298a..77ff9d0e 100644
--- a/MP.Data/DatabaseModels/InventorySessionModel.cs
+++ b/MP.Data/DatabaseModels/InventorySessionModel.cs
@@ -18,6 +18,7 @@ namespace MP.Data.DatabaseModels
public int InveSessID { get; set; }
public string Description { get; set; } = "";
public string UserCrea { get; set; } = "";
+ public int? MagID { get; set; } = null;
public DateTime DtStart { get; set; } = DateTime.Now;
public DateTime? DtEnd { get; set; } = null;
public bool Transferred { get; set; } = false;
@@ -33,5 +34,10 @@ namespace MP.Data.DatabaseModels
get => ((DtEnd != null && DtEnd > DtStart));
}
+ ///
+ /// Navigazione oggetto Magazzino
+ ///
+ [ForeignKey("MagID")]
+ public virtual AnagMagModel AnagMagNav { get; set; } = null;
}
}
diff --git a/MP.Data/Migrations/20221117105402_AddedAnagMag.Designer.cs b/MP.Data/Migrations/20221117105402_AddedAnagMag.Designer.cs
new file mode 100644
index 00000000..d7e6e374
--- /dev/null
+++ b/MP.Data/Migrations/20221117105402_AddedAnagMag.Designer.cs
@@ -0,0 +1,159 @@
+//
+using System;
+using MP.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace MP.Data.Migrations
+{
+ [DbContext(typeof(MoonPro_InveContext))]
+ [Migration("20221117105402_AddedAnagMag")]
+ partial class AddedAnagMag
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .UseCollation("SQL_Latin1_General_CP1_CI_AS")
+ .HasAnnotation("ProductVersion", "6.0.9")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
+
+ modelBuilder.Entity("MP.Data.DatabaseModels.AnagMagModel", b =>
+ {
+ b.Property("MagID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MagID"), 1L, 1);
+
+ b.Property("CodCS")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CodMag")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DescMag")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Nascosto")
+ .HasColumnType("bit");
+
+ b.HasKey("MagID");
+
+ b.ToTable("AnagMagazzini");
+ });
+
+ modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b =>
+ {
+ b.Property("InveSessID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InveSessID"), 1L, 1);
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DtEnd")
+ .HasColumnType("datetime2");
+
+ b.Property("DtStart")
+ .HasColumnType("datetime2");
+
+ b.Property("MagID")
+ .HasColumnType("int");
+
+ b.Property("Transferred")
+ .HasColumnType("bit");
+
+ b.Property("UserCrea")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("InveSessID");
+
+ b.HasIndex("MagID");
+
+ b.ToTable("InveSess");
+ });
+
+ modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b =>
+ {
+ b.Property("ScanID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ScanID"), 1L, 1);
+
+ b.Property("CodArticolo")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DtScan")
+ .HasColumnType("datetime2");
+
+ b.Property("InveSessID")
+ .HasColumnType("int");
+
+ b.Property("IsForced")
+ .HasColumnType("bit");
+
+ b.Property("IsKnown")
+ .HasColumnType("bit");
+
+ b.Property("IsUnique")
+ .HasColumnType("bit");
+
+ b.Property("Lotto")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Note")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Qty")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("RifExt")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ScanValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserScan")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("ScanID");
+
+ b.HasIndex("InveSessID");
+
+ b.ToTable("InveScanData");
+ });
+
+ modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b =>
+ {
+ b.HasOne("MP.Data.DatabaseModels.AnagMagModel", "AnagMagNav")
+ .WithMany()
+ .HasForeignKey("MagID");
+
+ b.Navigation("AnagMagNav");
+ });
+
+ modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b =>
+ {
+ b.HasOne("MP.Data.DatabaseModels.InventorySessionModel", "InveSessNav")
+ .WithMany()
+ .HasForeignKey("InveSessID")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("InveSessNav");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/MP.Data/Migrations/20221117105402_AddedAnagMag.cs b/MP.Data/Migrations/20221117105402_AddedAnagMag.cs
new file mode 100644
index 00000000..06e49afb
--- /dev/null
+++ b/MP.Data/Migrations/20221117105402_AddedAnagMag.cs
@@ -0,0 +1,64 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MP.Data.Migrations
+{
+ public partial class AddedAnagMag : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "MagID",
+ table: "InveSess",
+ type: "int",
+ nullable: true);
+
+ migrationBuilder.CreateTable(
+ name: "AnagMagazzini",
+ columns: table => new
+ {
+ MagID = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ CodMag = table.Column(type: "nvarchar(max)", nullable: true),
+ CodCS = table.Column(type: "nvarchar(max)", nullable: true),
+ DescMag = table.Column(type: "nvarchar(max)", nullable: true),
+ Nascosto = table.Column(type: "bit", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AnagMagazzini", x => x.MagID);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_InveSess_MagID",
+ table: "InveSess",
+ column: "MagID");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_InveSess_AnagMagazzini_MagID",
+ table: "InveSess",
+ column: "MagID",
+ principalTable: "AnagMagazzini",
+ principalColumn: "MagID");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_InveSess_AnagMagazzini_MagID",
+ table: "InveSess");
+
+ migrationBuilder.DropTable(
+ name: "AnagMagazzini");
+
+ migrationBuilder.DropIndex(
+ name: "IX_InveSess_MagID",
+ table: "InveSess");
+
+ migrationBuilder.DropColumn(
+ name: "MagID",
+ table: "InveSess");
+ }
+ }
+}
diff --git a/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs b/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs
index d28feafa..0eb5a9e7 100644
--- a/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs
+++ b/MP.Data/Migrations/MoonPro_InveContextModelSnapshot.cs
@@ -23,6 +23,31 @@ namespace MP.Data.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
+ modelBuilder.Entity("MP.Data.DatabaseModels.AnagMagModel", b =>
+ {
+ b.Property("MagID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MagID"), 1L, 1);
+
+ b.Property("CodCS")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CodMag")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DescMag")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Nascosto")
+ .HasColumnType("bit");
+
+ b.HasKey("MagID");
+
+ b.ToTable("AnagMagazzini");
+ });
+
modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b =>
{
b.Property("InveSessID")
@@ -40,6 +65,9 @@ namespace MP.Data.Migrations
b.Property("DtStart")
.HasColumnType("datetime2");
+ b.Property("MagID")
+ .HasColumnType("int");
+
b.Property("Transferred")
.HasColumnType("bit");
@@ -48,6 +76,8 @@ namespace MP.Data.Migrations
b.HasKey("InveSessID");
+ b.HasIndex("MagID");
+
b.ToTable("InveSess");
});
@@ -102,6 +132,15 @@ namespace MP.Data.Migrations
b.ToTable("InveScanData");
});
+ modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b =>
+ {
+ b.HasOne("MP.Data.DatabaseModels.AnagMagModel", "AnagMagNav")
+ .WithMany()
+ .HasForeignKey("MagID");
+
+ b.Navigation("AnagMagNav");
+ });
+
modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b =>
{
b.HasOne("MP.Data.DatabaseModels.InventorySessionModel", "InveSessNav")
diff --git a/MP.Data/ModelBuilderExtensions.cs b/MP.Data/ModelBuilderExtensions.cs
new file mode 100644
index 00000000..9d173fa3
--- /dev/null
+++ b/MP.Data/ModelBuilderExtensions.cs
@@ -0,0 +1,44 @@
+using Microsoft.EntityFrameworkCore;
+using MP.Data.DatabaseModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MP.Data
+{
+ public static class ModelBuilderExtensions
+ {
+ ///
+ /// Estensione per seed iniziale dei dati nel DB
+ ///
+ ///
+ public static void Seed(this ModelBuilder modelBuilder)
+ {
+ // initi valori default x magazini
+ modelBuilder.Entity().HasData(
+ new AnagMagModel { MagID = 0, CodMag = "00000", CodCS="NA", DescMag="Default" , Nascosto = true }
+ );
+
+#if false
+ // inizializzazione dei valori di default x USER
+ modelBuilder.Entity().HasData(
+ new UserModel { UserId = 1, AuthKey = "th1sIsTh3R1vrOfThNgt98", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "samuele.locatelli", Email = "samuele@steamware.net", Firstname = "Samuele", Lastname = "Locatelli" },
+ new UserModel { UserId = 2, AuthKey = "th1sIsTh3R1vrOfThNgt91", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "giancarlo.rottoli", Email = "giancarlo@steamware.net", Firstname = "Giancarlo", Lastname = "Rottoli" },
+ new UserModel { UserId = 3, AuthKey = "th1sIsTh3R1vrOfThNgt93", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "steamw.admin", Email = "info@steamware.net", Firstname = "Steamware", Lastname = "Admin" },
+ new UserModel { UserId = 4, AuthKey = "th1sIsTh3R1vrOfThNgt97", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "angelo.pizzaferri", Email = "a.pizzaferri@pizzaferripetroli.it", Firstname = "Angelo", Lastname = "Pizzaferri" },
+ new UserModel { UserId = 5, AuthKey = "th1sIsTh3R1vrOfThNgt99", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "andrei.valeanu", Email = "andrei.valeanu@winnlab.it", Firstname = "Andrei", Lastname = "Valeanu" },
+ new UserModel { UserId = 6, AuthKey = "th1sIsTh3R1vrOfThNgt92", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 1, MaskTranspId = 0, UserName = "liquigas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LIQUIGAS" },
+ new UserModel { UserId = 7, AuthKey = "th1sIsTh3R1vrOfThNgt94", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 2, MaskTranspId = 0, UserName = "vulkangas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "VULKANGAS" },
+ new UserModel { UserId = 8, AuthKey = "th1sIsTh3R1vrOfThNgt95", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 1, UserName = "levorato.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LEVORATO" },
+ new UserModel { UserId = 9, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 2, UserName = "traffik.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "TRAFFIK" },
+ new UserModel { UserId = 10, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 1, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz03.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Collecchio" },
+ new UserModel { UserId = 11, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 2, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz04.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Noceto" },
+ new UserModel { UserId = 12, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 3, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz05.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Baganzola" },
+ new UserModel { UserId = 13, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 4, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz08.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Pilastrello" }
+ );
+#endif
+ }
+ }
+}
diff --git a/MP.Data/MoonPro_InveContext.cs b/MP.Data/MoonPro_InveContext.cs
index c8844cb6..602bb9c6 100644
--- a/MP.Data/MoonPro_InveContext.cs
+++ b/MP.Data/MoonPro_InveContext.cs
@@ -45,6 +45,7 @@ namespace MP.Data
#region Public Properties
+ public virtual DbSet DbAnagMag { get; set; }
public virtual DbSet DbInveSess { get; set; }
public virtual DbSet DbScanData { get; set; }