Aggiunta tab anag magazzini

This commit is contained in:
Samuele Locatelli
2022-11-17 11:59:11 +01:00
parent a242302fd0
commit d3eedba82a
7 changed files with 340 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
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
}
}
@@ -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));
}
/// <summary>
/// Navigazione oggetto Magazzino
/// </summary>
[ForeignKey("MagID")]
public virtual AnagMagModel AnagMagNav { get; set; } = null;
}
}
+159
View File
@@ -0,0 +1,159 @@
// <auto-generated />
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<int>("MagID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("MagID"), 1L, 1);
b.Property<string>("CodCS")
.HasColumnType("nvarchar(max)");
b.Property<string>("CodMag")
.HasColumnType("nvarchar(max)");
b.Property<string>("DescMag")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Nascosto")
.HasColumnType("bit");
b.HasKey("MagID");
b.ToTable("AnagMagazzini");
});
modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b =>
{
b.Property<int>("InveSessID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("InveSessID"), 1L, 1);
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DtEnd")
.HasColumnType("datetime2");
b.Property<DateTime>("DtStart")
.HasColumnType("datetime2");
b.Property<int?>("MagID")
.HasColumnType("int");
b.Property<bool>("Transferred")
.HasColumnType("bit");
b.Property<string>("UserCrea")
.HasColumnType("nvarchar(max)");
b.HasKey("InveSessID");
b.HasIndex("MagID");
b.ToTable("InveSess");
});
modelBuilder.Entity("MP.Data.DatabaseModels.ScanDataModel", b =>
{
b.Property<int>("ScanID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ScanID"), 1L, 1);
b.Property<string>("CodArticolo")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DtScan")
.HasColumnType("datetime2");
b.Property<int>("InveSessID")
.HasColumnType("int");
b.Property<bool>("IsForced")
.HasColumnType("bit");
b.Property<bool>("IsKnown")
.HasColumnType("bit");
b.Property<bool>("IsUnique")
.HasColumnType("bit");
b.Property<string>("Lotto")
.HasColumnType("nvarchar(max)");
b.Property<string>("Note")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)");
b.Property<string>("RifExt")
.HasColumnType("nvarchar(max)");
b.Property<string>("ScanValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("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
}
}
}
@@ -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<int>(
name: "MagID",
table: "InveSess",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "AnagMagazzini",
columns: table => new
{
MagID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CodMag = table.Column<string>(type: "nvarchar(max)", nullable: true),
CodCS = table.Column<string>(type: "nvarchar(max)", nullable: true),
DescMag = table.Column<string>(type: "nvarchar(max)", nullable: true),
Nascosto = table.Column<bool>(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");
}
}
}
@@ -23,6 +23,31 @@ namespace MP.Data.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("MP.Data.DatabaseModels.AnagMagModel", b =>
{
b.Property<int>("MagID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("MagID"), 1L, 1);
b.Property<string>("CodCS")
.HasColumnType("nvarchar(max)");
b.Property<string>("CodMag")
.HasColumnType("nvarchar(max)");
b.Property<string>("DescMag")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Nascosto")
.HasColumnType("bit");
b.HasKey("MagID");
b.ToTable("AnagMagazzini");
});
modelBuilder.Entity("MP.Data.DatabaseModels.InventorySessionModel", b =>
{
b.Property<int>("InveSessID")
@@ -40,6 +65,9 @@ namespace MP.Data.Migrations
b.Property<DateTime>("DtStart")
.HasColumnType("datetime2");
b.Property<int?>("MagID")
.HasColumnType("int");
b.Property<bool>("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")
+44
View File
@@ -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
{
/// <summary>
/// Estensione per seed iniziale dei dati nel DB
/// </summary>
/// <param name="modelBuilder"></param>
public static void Seed(this ModelBuilder modelBuilder)
{
// initi valori default x magazini
modelBuilder.Entity<AnagMagModel>().HasData(
new AnagMagModel { MagID = 0, CodMag = "00000", CodCS="NA", DescMag="Default" , Nascosto = true }
);
#if false
// inizializzazione dei valori di default x USER
modelBuilder.Entity<UserModel>().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
}
}
}
+1
View File
@@ -45,6 +45,7 @@ namespace MP.Data
#region Public Properties
public virtual DbSet<AnagMagModel> DbAnagMag { get; set; }
public virtual DbSet<InventorySessionModel> DbInveSess { get; set; }
public virtual DbSet<ScanDataModel> DbScanData { get; set; }