Seed de 5 commande pour Admin
This commit is contained in:
@@ -14,7 +14,7 @@ public class InventoryContext : IdentityDbContext<InventoryUser> {
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder) {
|
||||
|
||||
|
||||
#region Products
|
||||
// Pour partir la BD.
|
||||
modelBuilder.Entity<ProductModel>().HasData(new ProductModel {
|
||||
Id = 1,
|
||||
@@ -369,8 +369,9 @@ Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumbl
|
||||
Quantity = 69,
|
||||
ImageName = @"$pika.png"
|
||||
});
|
||||
#endregion
|
||||
|
||||
|
||||
#region Users
|
||||
// Source: Notre TP Web 4DW.
|
||||
string AdministrateurID = "c9e08b20-d8a5-473f-9f52-572eb23c12af";
|
||||
string ClientID = "1b7b9c55-c746-493a-a24f-3d5ca937298e";
|
||||
@@ -386,15 +387,6 @@ Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumbl
|
||||
Email = "admin@admin.com"
|
||||
};
|
||||
|
||||
//admin.Adresses.Add(new AddressModel() {
|
||||
// CivicNumber = 1234,
|
||||
// Appartment = "B",
|
||||
// Street = "Rue Pierre-Falardeau",
|
||||
// City = "Saint-Chrysostome",
|
||||
// PostalCode = "H0H0H0",
|
||||
// Province = "QC",
|
||||
// Country = "Canada"
|
||||
//});
|
||||
|
||||
admin.PasswordHash = new PasswordHasher<InventoryUser>().HashPassword(admin, "Qwerty123!");
|
||||
modelBuilder.Entity<InventoryUser>().HasData(admin);
|
||||
@@ -408,6 +400,188 @@ Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumbl
|
||||
new IdentityUserRole<string> { RoleId = AdministrateurID, UserId = AdminID },
|
||||
new IdentityUserRole<string> { RoleId = ClientID, UserId = AdminID }
|
||||
);
|
||||
#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,
|
||||
}
|
||||
);
|
||||
#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,
|
||||
}
|
||||
);
|
||||
|
||||
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
|
||||
}
|
||||
);
|
||||
#endregion
|
||||
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
Reference in New Issue
Block a user