132 lines
9.0 KiB
C#
132 lines
9.0 KiB
C#
using Lux.Data.DbModel;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Lux.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)
|
|
{
|
|
// inizializzazione dei valori di default x Ruoli
|
|
modelBuilder.Entity<TagsModel>().HasData(
|
|
new TagsModel { TagID = 1, Description = "Tag 01" },
|
|
new TagsModel { TagID = 2, Description = "Tag 02" },
|
|
new TagsModel { TagID = 3, Description = "Tag 03" },
|
|
new TagsModel { TagID = 4, Description = "Tag 04" },
|
|
new TagsModel { TagID = 5, Description = "Tag 05" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Customer
|
|
modelBuilder.Entity<CustomerModel>().HasData(
|
|
new CustomerModel { CustomerID = 1, FirstName = "Customer A", LastName = "Egalware", VAT = "1234567890123456" },
|
|
new CustomerModel { CustomerID = 2, FirstName = "Customer B", LastName = "User", VAT = "1234567890123456" },
|
|
new CustomerModel { CustomerID = 3, FirstName = "Customer C", LastName = "User Test", VAT = "1234567890123456" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Dealer
|
|
modelBuilder.Entity<DealerModel>().HasData(
|
|
new DealerModel { DealerID = 1, CompanyName = "Company First", FirstName = "Dealer A", LastName = "Egalware", VAT = "9587362514671527" },
|
|
new DealerModel { DealerID = 2, CompanyName = "Company First", FirstName = "Dealer B", LastName = "User", VAT = "9587362514671527" },
|
|
new DealerModel { DealerID = 3, CompanyName = "Company Second", FirstName = "Dealer C", LastName = "User Test", VAT = "9587362514671527" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Supplier
|
|
modelBuilder.Entity<SupplierModel>().HasData(
|
|
new SupplierModel { SupplierID = 1, CompanyName = "Company One", FirstName = "Supplier A", LastName = "Egalware", VAT = "7294857103879254" },
|
|
new SupplierModel { SupplierID = 2, CompanyName = "Company Two", FirstName = "Supplier B", LastName = "User", VAT = "7294857103879254" },
|
|
new SupplierModel { SupplierID = 3, CompanyName = "Company Two", FirstName = "Supplier C", LastName = "User Test", VAT = "7294857103879254" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Item
|
|
modelBuilder.Entity<ItemModel>().HasData(
|
|
new ItemModel { ItemID = 1, IsService = false, Description = "Barra di legno 80x120", Cost = 50, Margin = 0.3 },
|
|
new ItemModel { ItemID = 2, IsService = false, Description = "Vernice trasparente", Cost = 35, Margin = 0.3 },
|
|
new ItemModel { ItemID = 3, IsService = false, Description = "Ferramenta", Cost = 1, Margin = 0.3 }
|
|
);
|
|
|
|
|
|
// inizializzazione risorse
|
|
modelBuilder.Entity<ResourceModel>().HasData(
|
|
new ResourceModel { ResourceID = 1, Description = "Sezionatrice", IsAsset = true, IsHuman = false, UnitCost = 15, UM = "€/h" },
|
|
new ResourceModel { ResourceID = 2, Description = "Linea SAOMAD WoodPecker Just 3500", IsAsset = true, IsHuman = false, UnitCost = 540, UM = "€/h" },
|
|
new ResourceModel { ResourceID = 3, Description = "Linea Pantografo", IsAsset = true, IsHuman = false, UnitCost = 250, UM = "€/h" },
|
|
new ResourceModel { ResourceID = 4, Description = "Stazione Verniciatura", IsAsset = true, IsHuman = false, UnitCost = 10, UM = "€/h" },
|
|
new ResourceModel { ResourceID = 5, Description = "Verniciatura Manuale", IsAsset = false, IsHuman = true, UnitCost = 40, UM = "€/h" },
|
|
new ResourceModel { ResourceID = 6, Description = "Montaggio Manuale", IsAsset = false, IsHuman = true, UnitCost = 40, UM = "€/h" },
|
|
new ResourceModel { ResourceID = 7, Description = "Installatore", IsAsset = false, IsHuman = true, UnitCost = 40, UM = "€/h" }
|
|
);
|
|
|
|
// inizializzazione fasi
|
|
modelBuilder.Entity<PhaseModel>().HasData(
|
|
new PhaseModel { PhaseID = 1, Description = "Taglio tronchetti" },
|
|
new PhaseModel { PhaseID = 2, Description = "Lavorazione pezzi serramento" },
|
|
new PhaseModel { PhaseID = 3, Description = "Verniciatura" },
|
|
new PhaseModel { PhaseID = 4, Description = "Assemblaggio completo" },
|
|
new PhaseModel { PhaseID = 5, Description = "Assemblaggio Ferramenta" },
|
|
new PhaseModel { PhaseID = 6, Description = "Installazione e posa in opera" }
|
|
|
|
);
|
|
|
|
// inizializzazione cicli
|
|
modelBuilder.Entity<JobModel>().HasData(
|
|
new JobModel { JobID = 1, Description = "Rivendita / servizi" },
|
|
new JobModel { JobID = 2, Description = "Serramento Completo Legno su linea Saomad e installatore interno" }//,
|
|
//new JobModel { JobID = 2, Description = "Serramento Completo Legno/Alluminio" },
|
|
//new JobModel { JobID = 3, Description = "Persiana Legno" },
|
|
//new JobModel { JobID = 4, Description = "restauro Persiana Esistente" }
|
|
);
|
|
|
|
// init righe ciclo (fasi di ciclo)
|
|
modelBuilder.Entity<JobRowModel>().HasData(
|
|
new JobRowModel { JobRowID = 1, JobID = 2, Index = 1, PhaseID = 1, Qty = 1, ResourceID = 1 },
|
|
new JobRowModel { JobRowID = 2, JobID = 2, Index = 2, PhaseID = 2, Qty = 1, ResourceID = 2 },
|
|
new JobRowModel { JobRowID = 3, JobID = 2, Index = 3, PhaseID = 4, Qty = 1, ResourceID = 6 },
|
|
new JobRowModel { JobRowID = 4, JobID = 2, Index = 4, PhaseID = 3, Qty = 1, ResourceID = 4 },
|
|
new JobRowModel { JobRowID = 5, JobID = 2, Index = 5, PhaseID = 5, Qty = 1, ResourceID = 6 },
|
|
new JobRowModel { JobRowID = 6, JobID = 2, Index = 6, PhaseID = 6, Qty = 1, ResourceID = 7 }
|
|
);
|
|
|
|
// init item righe ciclo (articoli delle fasi del ciclo)
|
|
modelBuilder.Entity<JobRowItemModel>().HasData(
|
|
new JobRowItemModel { JobRowItemID = 1, JobRowID = 1, Index = 1, ItemID = 1, Qty = 4.5, Description = "Grezzo legno abete" },
|
|
new JobRowItemModel { JobRowItemID = 2, JobRowID = 4, Index = 2, ItemID = 2, Qty = 1, Description = "Vernice trasparente standard 1L" },
|
|
new JobRowItemModel { JobRowItemID = 3, JobRowID = 5, Index = 3, ItemID = 3, Qty = 1, Description = "Ferramenta AGB - rif. AGFD.00000.00000" }
|
|
);
|
|
|
|
|
|
// inizializzazione dei valori di default x Item
|
|
modelBuilder.Entity<SellingItemModel>().HasData(
|
|
new SellingItemModel { SellingItemID = 1, IsService = false, Description = "Finestra anta Singola", Cost = 820, Margin = 0.2, JobID = 2 },
|
|
new SellingItemModel { SellingItemID = 2, IsService = false, Description = "Persiana anta singola", Cost = 150, Margin = 0.1, JobID = 1 },
|
|
new SellingItemModel { SellingItemID = 3, IsService = true, Description = "Installazione", Cost = 200, Margin = 0.3, JobID = 1 }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Offer
|
|
modelBuilder.Entity<OfferModel>().HasData(
|
|
new OfferModel { OfferID = 1, RefYear = 2024, RefNum = 1, RefRev = 1, Description = "Offerta per tre serramenti", CustomerID = 2, DealerID = 2 }
|
|
//new OfferModel { OfferID = 2, RefYear = 2025, RefNum = 2, RefRev = 1, Description = "Offerta per un serramento + installazione", CustomerID = 1, DealerID = 1 },
|
|
//new OfferModel { OfferID = 3, RefYear = 2025, RefNum = 3, RefRev = 1, Description = "Offerta per tre serramenti", CustomerID = 2, DealerID = 1 },
|
|
//new OfferModel { OfferID = 5, RefYear = 2025, RefNum = 4, RefRev = 2, Description = "Offerta per cinque serramenti + installazione", CustomerID = 3, DealerID = 2 }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x OfferRow
|
|
modelBuilder.Entity<OfferRowModel>().HasData(
|
|
new OfferRowModel { OfferRowID = 1, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 950, SellingItemID = 1, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Finestra anta singola 2025", ItemSPP = "{}" },
|
|
new OfferRowModel { OfferRowID = 2, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 160, SellingItemID = 2, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Persiana per Finestra anta singola 2025", ItemSPP = "{}" },
|
|
new OfferRowModel { OfferRowID = 3, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 200, SellingItemID = 3, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Installazione serramento", ItemSPP = "{}" }
|
|
);
|
|
|
|
|
|
}
|
|
}
|
|
}
|