Files
webdoorcreator/WebDoorCreator.Data/ModelBuilderExtensions.cs
2023-03-08 17:23:14 +01:00

91 lines
5.7 KiB
C#

using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Org.BouncyCastle.Utilities.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using WebDoorCreator.Data.DbModels;
namespace WebDoorCreator.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)
{
#if false
modelBuilder.Entity<IdentityRole>().HasData(new IdentityRole { Name = "SuperAdmin", NormalizedName = "SUPERADMIN" });
#endif
//aggiungo hasher per pw
//Creo la relazione tra utente e ruolo nella tabella userRoles
#if false
var hasher = new PasswordHasher<IdentityUser>();
// inizializzazione dei valori di default x USER
modelBuilder.Entity<IdentityUser>().HasData(
new IdentityUser
{
UserName = "zaccaria.majid@egalware.com",
Email = "zaccaria.majid@egalware.com",
NormalizedEmail = "ZACCARIA.MAJID@EGALWARE.COM",
EmailConfirmed = true,
PasswordHash = hasher.HashPassword(null, "Pa$$w0rd"),
});
modelBuilder.Entity<IdentityUserRole<string>>().HasData(
new IdentityUserRole<string>
{
UserId = "90a9d755-07ae-47cc-88f6-db08bfd133be",
RoleId = "654c700b-1fca-4701-89e4-c0d5ee32ff210"
});
#endif
//// inizializzazione dei valori di default x Plant
//modelBuilder.Entity<PlantDetailModel>().HasData(
// new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 },
// new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, LevelReorder = 15000, OrderQtyStd = 18000 },
// new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, LevelReorder = 15000, OrderQtyStd = 18000 },
// new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 },
// new PlantDetailModel { PlantId = 5, PlantCode = "PIZ09", PlantDesc = "Guardamiglio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 }
// // new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
// //new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
// //new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
// //new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }
// );
//// inizializzazione dei valori di default x Fornitori
//modelBuilder.Entity<SupplierModel>().HasData(
// new SupplierModel { SupplierId = 1, SupplierCode = "LIQUIGAS", SupplierDesc = "Liquigas" },
// new SupplierModel { SupplierId = 2, SupplierCode = "VULKANGAS", SupplierDesc = "Vulkangas" }
// );
//// inizializzazione dei valori di default x Trasportatori
//modelBuilder.Entity<TransporterModel>().HasData(
// new TransporterModel { TransporterId = 1, TransporterCode = "LEVO", TransporterDesc = "Levorato" },
// new TransporterModel { TransporterId = 2, TransporterCode = "TRAF", TransporterDesc = "Traffik" }
// );
//// init consegne...
//modelBuilder.Entity<WeekPlanModel>().HasData(
// new WeekPlanModel { WeekPlanId = 1, DayNum = DayOfWeek.Monday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 2, DayNum = DayOfWeek.Tuesday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 3, DayNum = DayOfWeek.Wednesday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 2 },
// new WeekPlanModel { WeekPlanId = 4, DayNum = DayOfWeek.Thursday, DeliveryHour = 15, Note = "9K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 5, DayNum = DayOfWeek.Thursday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 6, DayNum = DayOfWeek.Saturday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 7, DayNum = DayOfWeek.Tuesday, DeliveryHour = 14, Note = "3K", PlantId = 3, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 8, DayNum = DayOfWeek.Tuesday, DeliveryHour = 15, Note = "15K", PlantId = 4, SupplierId = 1, TransporterId = 1 },
// new WeekPlanModel { WeekPlanId = 9, DayNum = DayOfWeek.Tuesday, DeliveryHour = 17, Note = "18K", PlantId = 1, SupplierId = 2, TransporterId = 2 }
// );
}
}
}