GGMM/GrossesMitaines/GrossesMitainesAPI/Data/InventoryContext.cs

211 lines
7.7 KiB
C#
Raw Normal View History

2022-10-08 13:22:12 -04:00
using Microsoft.EntityFrameworkCore;
using GrossesMitainesAPI.Models;
namespace GrossesMitainesAPI.Data;
public class InventoryContext : DbContext {
public DbSet<Product> Products { get; set; }
public InventoryContext(DbContextOptions<InventoryContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder) {
base.OnModelCreating(modelBuilder);
// Pour partir la BD.
modelBuilder.Entity<Product>().HasData(new Product {
Id = 1,
2022-10-08 14:02:05 -04:00
Title = $"Ceinture flèchée",
2022-10-09 15:07:35 -04:00
Category = $"Linge",
2022-10-08 14:02:05 -04:00
Description = $"Pour faire votre propre bonhomme de 1837, comme dans le bon vieux temps.",
2022-10-16 11:25:21 -04:00
Status = Product.States.Promotion,
2022-10-08 14:02:05 -04:00
Price = 85.86M,
2022-10-18 10:51:13 -04:00
PromoPrice = 29.99M,
2022-10-09 15:07:35 -04:00
Quantity = 1,
2022-10-09 13:18:39 -04:00
ImageName = $"ceintureflechee"
2022-10-08 14:02:05 -04:00
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 2,
Title = $"Pantoufles du Canadien en Phentex",
2022-10-09 15:07:35 -04:00
Category = $"Linge",
2022-10-08 14:02:05 -04:00
Description = $"Parce que ça sent la coupe!",
2022-10-16 11:25:21 -04:00
Status = Product.States.Available,
2022-10-08 14:02:05 -04:00
Price = 15.64M,
2022-10-18 10:51:13 -04:00
PromoPrice = 9.99M,
2022-10-09 15:07:35 -04:00
Quantity = 54,
2022-10-09 13:18:39 -04:00
ImageName = $"pantouflesCH"
2022-10-08 14:02:05 -04:00
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 3,
Title = $"Jean-Luc Mongrain",
2022-10-09 15:07:35 -04:00
Category = $"Homme",
2022-10-08 14:02:05 -04:00
Description = $"On ne lui ferait pas mal, en tout cas!!",
2022-10-16 11:25:21 -04:00
Status = Product.States.Clearance,
2022-10-08 14:02:05 -04:00
Price = 1453.12M,
2022-10-18 10:51:13 -04:00
PromoPrice = 999.99M,
2022-10-09 15:07:35 -04:00
Quantity = 1,
2022-10-09 13:18:39 -04:00
ImageName = $"jeanlucmongrain"
2022-10-08 13:22:12 -04:00
});
2022-10-25 13:01:31 -04:00
modelBuilder.Entity<Product>().HasData(new Product {
Id = 4,
Title = $"T-Shirt",
Category = $"Linge",
Description = $"Tellement simple et comfortable.",
Status = Product.States.Available,
Price = 12.12M,
PromoPrice = 9.99M,
Quantity = 143,
ImageName = $"tshirt"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 5,
Title = $"Mitaines",
Category = $"Vêtement d'extérieur",
Description = $"Deux pour un!",
Status = Product.States.Available,
Price = 8.18M,
PromoPrice = 6.99M,
Quantity = 1423,
ImageName = $"mitaines"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 6,
Title = $"Foulard",
Category = $"Vêtement d'extérieur",
Description = $"Deux pour un!",
Status = Product.States.Promotion,
Price = 10.56M,
PromoPrice = 8.99M,
Quantity = 14,
ImageName = $"foulard"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 7,
Title = $"Jock-Strap en phentex",
Category = $"Sous-Vêtement",
Description = $"Pour garder le p'tit bout au chaud.",
Status = Product.States.Promotion,
Price = 15.45M,
PromoPrice = 12.99M,
Quantity = 144,
ImageName = $"kokin"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 8,
Title = $"Jock-Strap féminin en phentex",
Category = $"Sous-Vêtement",
Description = $"Pour garder l'absence de p'tit bout au chaud.",
Status = Product.States.Promotion,
Price = 15.45M,
PromoPrice = 12.99M,
Quantity = 224,
ImageName = $"kokin"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 9,
Title = $"Bibi",
Category = $"Alien",
Description = $"En chiffon.",
Status = Product.States.Clearance,
Price = 1045.45M,
PromoPrice = 1023.99M,
Quantity = 1,
ImageName = $"bibi"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 10,
Title = $"Tuque en laine",
Category = $"Vêtement d'extérieur",
Description = $"En chiffon.",
Status = Product.States.Available,
Price = 15.45M,
PromoPrice = 12.99M,
Quantity = 1,
ImageName = $"tuque"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 11,
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.",
Status = Product.States.Promotion,
Price = 145.45M,
PromoPrice = 123.99M,
Quantity = 1,
ImageName = $"bonhomme"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 12,
Title = $"Gauze en phentex",
Category = $"Autre",
Description = $"Pour se pêter la fiole avec style.",
Status = Product.States.BackOrder,
Price = 145.45M,
PromoPrice = 123.99M,
Quantity = 0,
ImageName = $"gauze"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 13,
Title = $"Petit Jésus de plâtre",
Category = $"Homme",
Description = $"En chiffon.",
Status = Product.States.Clearance,
Price = 145.45M,
PromoPrice = 123.99M,
Quantity = 1,
ImageName = $"jesus"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 14,
Title = $"VHS de la Guerre des Tuques",
Category = $"Autre",
Description = $"À écouter dans l'habit de Bonhomme Carnaval tant que possible.",
Status = Product.States.Clearance,
Price = 3.45M,
PromoPrice = 1.99M,
Quantity = 164363,
ImageName = $"vhs"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 15,
Title = $"Gilet pare-balle en laine",
Category = $"Linge",
Description = $"(N'est pas réellement pare-balle).",
Status = Product.States.Clearance,
Price = 1435.45M,
PromoPrice = 1223.99M,
Quantity = 18,
ImageName = $"chandailquetaine"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 16,
Title = $"Doudou",
Category = $"Autre",
Description = $"Pour s'éffoirer le nez dedans.",
Status = Product.States.Available,
Price = 14.45M,
PromoPrice = 13.99M,
Quantity = 14,
ImageName = $"doudou"
});
modelBuilder.Entity<Product>().HasData(new Product {
Id = 17,
Title = $"Mitaines pas de doigts",
Category = $"Vêtements d'extérieur",
Description = $"Pour avoir l'air thug en hiver.",
Status = Product.States.Available,
Price = 9.45M,
PromoPrice = 8.99M,
Quantity = 16,
ImageName = $"mitaines2"
});
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);
}
}