2022-10-08 13:22:12 -04:00
using Microsoft.EntityFrameworkCore ;
using GrossesMitainesAPI.Models ;
2022-10-30 16:58:47 -04:00
using Microsoft.AspNetCore.Identity.EntityFrameworkCore ;
using Microsoft.AspNetCore.Identity ;
2022-10-08 13:22:12 -04:00
namespace GrossesMitainesAPI.Data ;
2022-10-30 16:58:47 -04:00
public class InventoryContext : IdentityDbContext < InventoryUser > {
2022-11-01 13:33:08 -04:00
public DbSet < ProductModel > Products { get ; set ; }
public DbSet < AddressModel > Addresses { get ; set ; }
public DbSet < InvoiceModel > Invoices { get ; set ; }
2022-11-14 10:19:33 -05:00
//public DbSet<InvoiceModel.ProductInvoice> ProductInvoice { get; set; }
2022-11-01 13:33:08 -04:00
2022-10-08 13:22:12 -04:00
public InventoryContext ( DbContextOptions < InventoryContext > options ) : base ( options ) { }
protected override void OnModelCreating ( ModelBuilder modelBuilder ) {
2022-11-07 20:33:20 -05:00
2022-11-07 22:13:11 -05:00
#region Products
2022-10-08 13:22:12 -04:00
// Pour partir la BD.
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-08 13:22:12 -04:00
Id = 1 ,
2022-11-07 19:53:38 -05:00
Title = @"Ceinture flèchée" ,
Category = @"Linge" ,
Description = @"Pour faire votre propre bonhomme de 1837, comme dans le bon vieux temps." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Promotion ,
2022-10-08 14:02:05 -04:00
Price = 85.86 M ,
2022-10-18 10:51:13 -04:00
PromoPrice = 29.99 M ,
2022-10-09 15:07:35 -04:00
Quantity = 1 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$ceintureflechee.jpg"
2022-10-08 14:02:05 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-08 14:02:05 -04:00
Id = 2 ,
2022-11-07 19:53:38 -05:00
Title = @"Pantoufles du Canadien en Phentex" ,
Category = @"Linge" ,
Description = @"Parce que ça sent la coupe!" ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Available ,
2022-10-08 14:02:05 -04:00
Price = 15.64 M ,
2022-10-18 10:51:13 -04:00
PromoPrice = 9.99 M ,
2022-10-09 15:07:35 -04:00
Quantity = 54 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$pantouflesCH.jpg"
2022-10-08 14:02:05 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-08 14:02:05 -04:00
Id = 3 ,
2022-11-07 19:53:38 -05:00
Title = @"Jean-Luc Mongrain" ,
Category = @"Homme" ,
Description = @"On ne lui ferait pas mal, en tout cas!!" ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Clearance ,
2022-10-08 14:02:05 -04:00
Price = 1453.12 M ,
2022-10-18 10:51:13 -04:00
PromoPrice = 999.99 M ,
2022-10-09 15:07:35 -04:00
Quantity = 1 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$jeanlucmongrain.jpg"
2022-10-08 13:22:12 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 4 ,
2022-11-07 19:53:38 -05:00
Title = @"T-Shirt" ,
Category = @"Linge" ,
Description = @"Tellement simple et comfortable." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Available ,
2022-10-25 13:01:31 -04:00
Price = 12.12 M ,
PromoPrice = 9.99 M ,
Quantity = 143 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$tshirt.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 5 ,
2022-11-07 19:53:38 -05:00
Title = @"Mitaines" ,
Category = @"Vêtement d'extérieur" ,
Description = @"Deux pour un!" ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Available ,
2022-10-25 13:01:31 -04:00
Price = 8.18 M ,
PromoPrice = 6.99 M ,
Quantity = 1423 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$mitaines.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 6 ,
2022-11-07 19:53:38 -05:00
Title = @"Foulard" ,
Category = @"Vêtement d'extérieur" ,
Description = @"Deux pour un!" ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Promotion ,
2022-10-25 13:01:31 -04:00
Price = 10.56 M ,
PromoPrice = 8.99 M ,
Quantity = 14 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$foulard.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 7 ,
2022-11-07 19:53:38 -05:00
Title = @"Jock-Strap en phentex" ,
Category = @"Sous-Vêtement" ,
Description = @"Pour garder le p'tit bout au chaud." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Promotion ,
2022-10-25 13:01:31 -04:00
Price = 15.45 M ,
PromoPrice = 12.99 M ,
Quantity = 144 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$kokin.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 8 ,
2022-11-07 19:53:38 -05:00
Title = @"Jock-Strap féminin en phentex" ,
Category = @"Sous-Vêtement" ,
Description = @"Pour garder l'absence de p'tit bout au chaud." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Promotion ,
2022-10-25 13:01:31 -04:00
Price = 15.45 M ,
PromoPrice = 12.99 M ,
Quantity = 224 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$kokinfemme.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 9 ,
2022-11-07 19:53:38 -05:00
Title = @"Bibi" ,
Category = @"Alien" ,
Description = @"En chiffon." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Clearance ,
2022-10-25 13:01:31 -04:00
Price = 1045.45 M ,
PromoPrice = 1023.99 M ,
Quantity = 1 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$bibi.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 10 ,
2022-11-07 19:53:38 -05:00
Title = @"Tuque en laine" ,
Category = @"Vêtement d'extérieur" ,
Description = @"En chiffon." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Available ,
2022-10-25 13:01:31 -04:00
Price = 15.45 M ,
PromoPrice = 12.99 M ,
Quantity = 1 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$tuque.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 11 ,
2022-11-07 19:53:38 -05:00
Title = @"Habit de Bonhomme Carnaval" ,
Category = @"Vêtement d'extérieur" ,
Description = @"Pour se faire taper dessus avec une poêle à frire tout en restant au chaud." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Promotion ,
2022-10-25 13:01:31 -04:00
Price = 145.45 M ,
PromoPrice = 123.99 M ,
Quantity = 1 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$bonhomme.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 12 ,
2022-11-07 19:53:38 -05:00
Title = @"Gauze en phentex" ,
Category = @"Autre" ,
Description = @"Pour se pêter la fiole avec style." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . BackOrder ,
2022-10-25 13:01:31 -04:00
Price = 145.45 M ,
PromoPrice = 123.99 M ,
Quantity = 0 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$gauze.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 13 ,
2022-11-07 19:53:38 -05:00
Title = @"Petit Jésus de plâtre" ,
Category = @"Homme" ,
Description = @"En chiffon." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Clearance ,
2022-10-25 13:01:31 -04:00
Price = 145.45 M ,
PromoPrice = 123.99 M ,
Quantity = 1 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$jesus.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 14 ,
2022-11-07 19:53:38 -05:00
Title = @"VHS de la Guerre des Tuques" ,
Category = @"Autre" ,
Description = @"À écouter dans l'habit de Bonhomme Carnaval tant que possible." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Clearance ,
2022-10-25 13:01:31 -04:00
Price = 3.45 M ,
PromoPrice = 1.99 M ,
2022-11-08 00:58:55 -05:00
Quantity = 99 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$vhs.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 15 ,
2022-11-07 19:53:38 -05:00
Title = @"Gilet pare-balle en laine" ,
Category = @"Linge" ,
Description = @"(N'est pas réellement pare-balle)." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Clearance ,
2022-10-25 13:01:31 -04:00
Price = 1435.45 M ,
PromoPrice = 1223.99 M ,
Quantity = 18 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$chandailquetaine.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 16 ,
2022-11-07 19:53:38 -05:00
Title = @"Doudou" ,
Category = @"Autre" ,
Description = @"Pour s'éffoirer le nez dedans." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Available ,
2022-10-25 13:01:31 -04:00
Price = 14.45 M ,
PromoPrice = 13.99 M ,
Quantity = 14 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$doudou.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
2022-10-25 13:01:31 -04:00
Id = 17 ,
2022-11-07 19:53:38 -05:00
Title = @"Mitaines pas de doigts" ,
Category = @"Vêtements d'extérieur" ,
Description = @"Pour avoir l'air thug en hiver." ,
2022-11-01 13:33:08 -04:00
Status = ProductModel . States . Available ,
2022-10-25 13:01:31 -04:00
Price = 9.45 M ,
PromoPrice = 8.99 M ,
Quantity = 16 ,
2022-11-07 19:53:38 -05:00
ImageName = @"$mitaines2.jpg"
2022-10-25 13:01:31 -04:00
} ) ;
2022-11-07 20:33:20 -05:00
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 18 ,
Title = @"Longues mitaines pas de doigts" ,
Category = @"Vêtements d'extérieur" ,
Description = @"Pour avoir plus l'air thug en hiver." ,
Status = ProductModel . States . Discontinued ,
Price = 10.45 M ,
PromoPrice = 9.99 M ,
Quantity = 10 ,
ImageName = @"$longmitaines.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 19 ,
Title = @"Pantalons slacks" ,
Category = @"Linge" ,
Description = @"Pour les journées bs" ,
Status = ProductModel . States . BackOrder ,
Price = 69.99 M ,
PromoPrice = 49.99 M ,
Quantity = 0 ,
ImageName = @"$pantalon.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 20 ,
Title = @"Programmer Socks" ,
Category = @"Linge" ,
Description = @"Pour commencer à apprendre rust et utiliser linux" ,
Status = ProductModel . States . Promotion ,
Price = 23.50 M ,
PromoPrice = 19.99 M ,
Quantity = 3 ,
ImageName = @"$thighs.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 21 ,
Title = @"Col-roulé" ,
Category = @"Linge" ,
Description = @"Show off que t'habites su'l plateau" ,
Status = ProductModel . States . Available ,
Price = 149.99 M ,
PromoPrice = 99.99 M ,
Quantity = 14 ,
ImageName = @"$plateau.png"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 22 ,
Title = @"Gros col-roulé" ,
Category = @"Linge" ,
Description = @"Ben oui je vais à l'UQAM comment t'as d'viné" ,
Status = ProductModel . States . Clearance ,
Price = 149.99 M ,
PromoPrice = 99.99 M ,
Quantity = 4 ,
ImageName = @"$uqam.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 23 ,
Title = @"SAQ" ,
Category = @"Établissement" ,
Description = @"Oui oui, une SAQ au complete" ,
Status = ProductModel . States . Available ,
Price = 1000000.99 M ,
PromoPrice = 999999.99 M ,
Quantity = 1 ,
ImageName = @"$saq.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 24 ,
Title = @"Lorem" ,
Category = @"Texte" ,
Description = @ "Lorem ipsum dolor sit amet,
consectetur adipiscing elit . Vivamus sapien ipsum ,
convallis quis justo ac , congue sollicitudin metus .
Vestibulum nec libero nulla . Integer a pretium dolor .
Phasellus vulputate iaculis ligula , sit amet suscipit
diam condimentum eu . Suspendisse blandit ipsum sed porttitor volutpat .
Duis iaculis mauris a dapibus bibendum . Integer sollicitudin nunc et neque
egestas sagittis . Etiam vitae ornare ex . ",
Status = ProductModel . States . Promotion ,
Price = 0.99 M ,
PromoPrice = 0.69 M ,
Quantity = 99 ,
ImageName = @"$lorem.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 25 ,
Title = @"Bébé de laine" ,
Category = @"Homme" ,
Description = @"Quand un vrai coûte trop cher" ,
Status = ProductModel . States . Available ,
Price = 10.99 M ,
PromoPrice = 5.99 M ,
Quantity = 15 ,
ImageName = @"$bebe.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 26 ,
Title = @"Kit pour bébé" ,
Category = @"Linge" ,
Description = @"Un beau petit kit pas cher quand vous avez oublié le cadeau pour le shower qui s'en vient" ,
Status = ProductModel . States . Clearance ,
Price = 39.99 M ,
PromoPrice = 29.99 M ,
Quantity = 10 ,
ImageName = @"$kitbebe.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 27 ,
Title = @"TORTUE" ,
Category = @"Linge" ,
Description = @"Chris Pratt aime ben sauter dessus" ,
Status = ProductModel . States . Discontinued ,
Price = 29.99 M ,
PromoPrice = 9.99 M ,
Quantity = 0 ,
ImageName = @"$koopa.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 28 ,
Title = @"Patate de laine" ,
Category = @"Nourriture" ,
Description = @"*ne pa manger" ,
Status = ProductModel . States . Available ,
Price = 1.99 M ,
PromoPrice = 0.99 M ,
Quantity = 58 ,
ImageName = @"$potato.jpg"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 29 ,
Title = @"Monke :)" ,
Category = @"Animal" ,
Description = @ "Les singes sont des mammifères de l'ordre des primates, généralement arboricoles, à la face souvent glabre et caractérisés par un encéphale développé et de longs membres terminés par des doigts. Bien que leur ressemblance avec l'Homme ait toujours frappé les esprits, la science a mis de nombreux siècles à prouver le lien étroit qui existe entre ceux-ci et l'espèce humaine.
Au sein des primates , les singes forment un infra - ordre monophylétique , si l ' on y inclut le genre Homo , nommé Simiiformes et qui se divise entre les Platyrhiniens ( singes du Nouveau Monde : Amérique centrale et méridionale ) et les Catarhiniens ( singes de l ' Ancien Monde : Afrique et Asie tropicales ) . Ces derniers comprennent les hominoïdes , é galement appelés « grands singes » , dont fait partie Homo sapiens et ses ancêtres les plus proches .
Même s ' il ne fait plus de doute aujourd ' hui que « l ' Homme est un singe comme les autres » , l ' expression est majoritairement utilisée pour parler des animaux sauvages , et é voque un référentiel culturel , littéraire et artistique qui exclut l ' espèce humaine . ",
Status = ProductModel . States . Available ,
Price = 299.99 M ,
PromoPrice = 99.99 M ,
Quantity = 58 ,
ImageName = @"$monke.png"
} ) ;
modelBuilder . Entity < ProductModel > ( ) . HasData ( new ProductModel {
Id = 30 ,
Title = @"Phat Pikachu" ,
Category = @"Pokemon" ,
Description = @ "It evolves from Pichu when leveled up with high friendship and evolves into Raichu when exposed to a Thunder Stone.
In Alola , Pikachu will evolve into Alolan Raichu when exposed to a Thunder Stone .
Pikachu has a Gigantamax form . Pikachu with the Gigantamax Factor cannot evolve .
In Pokémon Yellow , the starter Pikachu will refuse to evolve into Raichu unless it is traded and evolved on another save file . In Pokémon : Let ' s Go , Pikachu ! , the player ' s starter Pikachu also will not evolve , but cannot be traded to become a Raichu .
Pikachu is popularly known as the mascot of the Pokémon franchise and one of Nintendo ' s major mascots .
It is also the game mascot and starter Pokémon of Pokémon Yellow and Let ' s Go , Pikachu ! . It has made numerous appearances on the boxes of spin - off titles .
Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumble World . ",
Status = ProductModel . States . Discontinued ,
Price = 3.99 M ,
PromoPrice = 2.99 M ,
Quantity = 69 ,
ImageName = @"$pika.png"
} ) ;
2022-11-07 22:13:11 -05:00
#endregion
2022-11-07 20:33:20 -05:00
2022-11-07 22:13:11 -05:00
#region Users
2022-11-01 13:33:08 -04:00
// Source: Notre TP Web 4DW.
2022-11-07 22:50:41 -05:00
//RolesID
2022-11-01 13:33:08 -04:00
string AdministrateurID = "c9e08b20-d8a5-473f-9f52-572eb23c12af" ;
string ClientID = "1b7b9c55-c746-493a-a24f-3d5ca937298e" ;
2022-11-07 22:50:41 -05:00
//UsersID
2022-11-01 13:33:08 -04:00
string AdminID = "ecf7503a-591c-454e-a824-048e10bd0474" ;
2022-11-07 22:50:41 -05:00
string PaulID = "af9178c8-1a02-4ff8-bc0a-c8248dad6e09" ;
2022-11-01 13:33:08 -04:00
2022-11-07 20:33:20 -05:00
InventoryUser admin = new InventoryUser ( ) {
2022-11-01 13:33:08 -04:00
FirstName = "Roger" ,
LastName = "Admin" ,
2022-11-07 20:33:20 -05:00
NormalizedUserName = "ADMIN" ,
UserName = "Admin" ,
2022-11-08 05:37:12 -05:00
PhoneNumber = "111-111-1111" ,
2022-11-07 20:33:20 -05:00
Id = AdminID ,
NormalizedEmail = "ADMIN@ADMIN.COM" ,
Email = "admin@admin.com"
2022-11-01 13:33:08 -04:00
} ;
2022-11-07 22:50:41 -05:00
InventoryUser paul = new InventoryUser ( ) {
FirstName = "Paul" ,
LastName = "A." ,
NormalizedUserName = "PASLA" ,
UserName = "PasLa" ,
2022-11-08 05:37:12 -05:00
PhoneNumber = "222-222-2222" ,
2022-11-07 22:50:41 -05:00
Id = PaulID ,
NormalizedEmail = "PAUL@EXEMPLE.COM" ,
Email = "paul@exemple.com"
} ;
2022-11-07 20:33:20 -05:00
2022-10-30 16:58:47 -04:00
admin . PasswordHash = new PasswordHasher < InventoryUser > ( ) . HashPassword ( admin , "Qwerty123!" ) ;
2022-11-07 22:50:41 -05:00
paul . PasswordHash = new PasswordHasher < InventoryUser > ( ) . HashPassword ( paul , "Qwerty123!" ) ;
modelBuilder . Entity < InventoryUser > ( ) . HasData ( admin , paul ) ;
2022-11-01 12:24:04 -04:00
2022-11-01 13:33:08 -04:00
modelBuilder . Entity < IdentityRole > ( ) . HasData (
new IdentityRole { Id = AdministrateurID , Name = "Administrateur" , NormalizedName = "ADMINISTRATEUR" } ,
new IdentityRole { Id = ClientID , Name = "Client" , NormalizedName = "CLIENT" }
) ;
modelBuilder . Entity < IdentityUserRole < string > > ( ) . HasData (
new IdentityUserRole < string > { RoleId = AdministrateurID , UserId = AdminID } ,
2022-11-07 22:50:41 -05:00
new IdentityUserRole < string > { RoleId = ClientID , UserId = AdminID } ,
new IdentityUserRole < string > { RoleId = ClientID , UserId = PaulID }
2022-11-01 13:33:08 -04:00
) ;
2022-11-07 22:13:11 -05:00
#endregion
#region Addresses
modelBuilder . Entity < AddressModel > ( ) . HasData (
new {
Id = 1 ,
CivicNumber = 1234 ,
Appartment = "B" ,
Street = "Rue Pierre-Falardeau" ,
City = "Saint-Chrysostome" ,
PostalCode = "H0H0H0" ,
Province = "QC" ,
Country = "Canada" ,
InventoryUserId = AdminID ,
2022-11-07 22:41:21 -05:00
} ,
new {
Id = 2 ,
CivicNumber = 420 ,
Street = "Rue MikeWard" ,
City = "Saint-Jérôme" ,
PostalCode = "H0H0H0" ,
Province = "QC" ,
Country = "Canada" ,
2022-11-07 22:50:41 -05:00
} ,
new {
Id = 3 ,
CivicNumber = 69 ,
Appartment = "A" ,
Street = "Rue PSPP" ,
City = "Saint-Québec" ,
PostalCode = "H0H0H0" ,
Province = "QC" ,
Country = "Canada" ,
InventoryUserId = PaulID ,
2022-11-07 22:13:11 -05:00
}
) ;
#endregion
#region Invoices
modelBuilder . Entity < InvoiceModel > ( ) . HasData (
new {
Id = 1 ,
EmailAddress = "admin@admin.com" ,
FirstName = "Roger" ,
LastName = "Admin" ,
LinkedAccountId = AdminID ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 1 ,
Status = InvoiceModel . InStates . Confirmed ,
} ,
new {
Id = 2 ,
EmailAddress = "admin@admin.com" ,
FirstName = "Roger" ,
LastName = "Admin" ,
LinkedAccountId = AdminID ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 1 ,
Status = InvoiceModel . InStates . Cancelled ,
} ,
new {
Id = 3 ,
EmailAddress = "admin@admin.com" ,
FirstName = "Roger" ,
LastName = "Admin" ,
LinkedAccountId = AdminID ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 1 ,
Status = InvoiceModel . InStates . Shipping ,
} ,
new {
Id = 4 ,
EmailAddress = "admin@admin.com" ,
FirstName = "Roger" ,
LastName = "Admin" ,
LinkedAccountId = AdminID ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 1 ,
Status = InvoiceModel . InStates . Shipped ,
} ,
new {
Id = 5 ,
EmailAddress = "admin@admin.com" ,
FirstName = "Roger" ,
LastName = "Admin" ,
LinkedAccountId = AdminID ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 1 ,
Status = InvoiceModel . InStates . Returned ,
2022-11-07 22:41:21 -05:00
} ,
new {
Id = 6 ,
EmailAddress = "test@admin.com" ,
FirstName = "Jérémy" ,
LastName = "Le Petit" ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 2 ,
Status = InvoiceModel . InStates . Confirmed ,
2022-11-07 22:50:41 -05:00
} ,
new {
Id = 7 ,
EmailAddress = "paul@exemple.com" ,
FirstName = "Paul" ,
LastName = "A." ,
LinkedAccountId = PaulID ,
PhoneNumber = "111-111-1111" ,
PurchaseDate = DateTime . Now ,
ShippingAddressId = 3 ,
Status = InvoiceModel . InStates . Shipping ,
}
2022-11-07 22:13:11 -05:00
) ;
modelBuilder . Entity < InvoiceModel . ProductInvoice > ( ) . HasData (
// invoice 1
new {
Id = 1 ,
ProductId = 1 ,
Quantity = ( uint ) 2 ,
InvoiceModelId = 1
} ,
new {
Id = 2 ,
ProductId = 4 ,
Quantity = ( uint ) 5 ,
InvoiceModelId = 1
} ,
// invoice 2
new {
Id = 3 ,
ProductId = 3 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 2
} ,
new {
Id = 4 ,
ProductId = 5 ,
Quantity = ( uint ) 2 ,
InvoiceModelId = 2
} ,
new {
Id = 5 ,
ProductId = 7 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 2
} ,
// invoice 3
new {
Id = 6 ,
ProductId = 9 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 3
} ,
new {
Id = 7 ,
ProductId = 11 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 3
} ,
// invoice 4
new {
Id = 8 ,
ProductId = 14 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 4
} ,
new {
Id = 9 ,
ProductId = 13 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 4
} ,
new {
Id = 10 ,
ProductId = 16 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 4
} ,
new {
Id = 11 ,
ProductId = 24 ,
Quantity = ( uint ) 25 ,
InvoiceModelId = 4
} ,
// invoice 5
new {
Id = 12 ,
ProductId = 25 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 5
} ,
new {
Id = 13 ,
ProductId = 29 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 5
} ,
new {
Id = 14 ,
ProductId = 30 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 5
} ,
new {
Id = 15 ,
ProductId = 15 ,
Quantity = ( uint ) 2 ,
InvoiceModelId = 5
2022-11-07 22:41:21 -05:00
} ,
// invoice 6
new {
Id = 16 ,
ProductId = 20 ,
Quantity = ( uint ) 4 ,
InvoiceModelId = 6
2022-11-07 22:50:41 -05:00
} ,
// invoice 7
new {
Id = 17 ,
ProductId = 1 ,
Quantity = ( uint ) 1 ,
InvoiceModelId = 7
} ,
new {
Id = 18 ,
ProductId = 15 ,
Quantity = ( uint ) 2 ,
InvoiceModelId = 7
2022-11-07 22:13:11 -05:00
}
) ;
#endregion
2022-11-01 13:33:08 -04:00
base . OnModelCreating ( modelBuilder ) ;
2022-10-08 13:22:12 -04:00
}
protected override void OnConfiguring ( DbContextOptionsBuilder optionsBuilder ) {
var configuration = new ConfigurationBuilder ( )
. SetBasePath ( Directory . GetCurrentDirectory ( ) )
. AddJsonFile ( "appsettings.json" )
. Build ( ) ;
var connectionString = configuration . GetConnectionString ( "DefaultConnection" ) ;
optionsBuilder . UseSqlServer ( connectionString ) ;
}
}