public static HomeBoothDbContext GetContext() { var operationalStoreOptions = Options.Create(new OperationalStoreOptions { }); var builderOptions = new DbContextOptionsBuilder <HomeBoothDbContext>() .EnableSensitiveDataLogging() .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; var testContext = new HomeBoothDbContext(builderOptions, operationalStoreOptions); SeedTestContext(testContext); return(testContext); }
public StudioListingService(HomeBoothDbContext homeBoothDbContext, IMapper mapper) { _db = homeBoothDbContext; _mapper = mapper; }
public HostService(IMapper mapper, HomeBoothDbContext context) { _mapper = mapper; _db = context; }
private static HomeBoothDbContext SeedTestContext(HomeBoothDbContext testContext) { List <Client> testClients = new() { new Client { Id = "id1", CreatedOn = DateTime.UtcNow, Email = "*****@*****.**", FirstName = "Basil", LastName = "Pilsner", PhoneNumber = "XXX-XXX-XXXX", }, new Client { Id = "id2", CreatedOn = DateTime.UtcNow, Email = "*****@*****.**", FirstName = "Fatboi", LastName = "Pilsner", PhoneNumber = "XXX-XXX-XXXX", }, }; List <Host> testHosts = new() { new Host { Id = "1", CreatedOn = DateTime.UtcNow, Email = "*****@*****.**", FirstName = "Roger", LastName = "Waters", PhoneNumber = "XXX-XXX-XXX" }, new Host { Id = "2", CreatedOn = DateTime.UtcNow, Email = "*****@*****.**", FirstName = "David", LastName = "Gilmour", PhoneNumber = "XXX-XXX-XXX" }, }; Studio testStudio = new() { Id = 2, CreatedOn = DateTime.UtcNow, Name = "The Hive", Host = testHosts[0], Address = new StudioAddress { AddressLine1 = "3522 Oak Ave", AddressLine2 = "", City = "Nashville", State = "TN", PostalCode = "23428", Country = "USA", CreatedOn = DateTime.UtcNow, }, Description = "We are the best studio", Services = new List <StudioService> { new StudioService { Description = "The best producing ever", ServiceName = "Mixing" }, new StudioService { Description = "The best mastering ever", ServiceName = "Mastering" }, }, Rate = 20, StudioItems = new List <StudioItem> { new StudioItem { Name = "SM57", ItemType = "Microphone", Condition = "New", Quanitity = 4, CreatedOn = DateTime.UtcNow, } }, Schedules = new List <StudioSchedule> { new StudioSchedule { } }, IsBooked = false, }; testContext.Hosts.AddRange(testHosts); testContext.Clients.AddRange(testClients); testContext.Studios.Add(testStudio); testContext.SaveChanges(); foreach (var entity in testContext.ChangeTracker.Entries()) { entity.State = EntityState.Detached; } return(testContext); }
public ClientService(IMapper mapper, HomeBoothDbContext dbContext) { _mapper = mapper; _db = dbContext; }