initial commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using Indotalent.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Infrastructure.Database.Demo;
|
||||
|
||||
public static class BookingResourceSeeder
|
||||
{
|
||||
public static async Task GenerateDataAsync(AppDbContext context)
|
||||
{
|
||||
if (await context.BookingResource.AnyAsync()) return;
|
||||
|
||||
var vehicleGroup = await context.BookingGroup.Where(x => x.Name == "Vehicle").SingleOrDefaultAsync();
|
||||
if (vehicleGroup != null)
|
||||
{
|
||||
var vehicleResources = new List<BookingResource>
|
||||
{
|
||||
new BookingResource { Name = "Audi 01", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "Audi 02", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "Audi 03", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "BMW 01", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "BMW 02", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "BMW 03", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "Lexus 01", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "Lexus 02", BookingGroupId = vehicleGroup.Id },
|
||||
new BookingResource { Name = "Lexus 03", BookingGroupId = vehicleGroup.Id }
|
||||
};
|
||||
|
||||
await context.BookingResource.AddRangeAsync(vehicleResources);
|
||||
}
|
||||
|
||||
var roomGroup = await context.BookingGroup.Where(x => x.Name == "Room").SingleOrDefaultAsync();
|
||||
if (roomGroup != null)
|
||||
{
|
||||
var roomResources = new List<BookingResource>
|
||||
{
|
||||
new BookingResource { Name = "Room One", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Room Two", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Room Three", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Conference One", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Conference Two", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Conference Three", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Studio One", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Studio Two", BookingGroupId = roomGroup.Id },
|
||||
new BookingResource { Name = "Studio Three", BookingGroupId = roomGroup.Id }
|
||||
};
|
||||
|
||||
await context.BookingResource.AddRangeAsync(roomResources);
|
||||
}
|
||||
|
||||
var electronicGroup = await context.BookingGroup.Where(x => x.Name == "Electronic").SingleOrDefaultAsync();
|
||||
if (electronicGroup != null)
|
||||
{
|
||||
var electronicResources = new List<BookingResource>
|
||||
{
|
||||
new BookingResource { Name = "Epson Projector", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Sony Projector", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Bose Speaker", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "JBL Speaker", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Microsoft Webcam", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Logitech Webcam", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Google Chromecast", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Apple TV", BookingGroupId = electronicGroup.Id },
|
||||
new BookingResource { Name = "Samsung Monitor 49", BookingGroupId = electronicGroup.Id }
|
||||
};
|
||||
|
||||
await context.BookingResource.AddRangeAsync(electronicResources);
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user