private static void Main(string[] args) { _venueRepository = new VenueRepository(); _seatSectionRepository = new SeatSectionRepository(); _senders = new List <ISender> { new EventHubSender(), new DocumentDbSender() }; while (true) { // Generate a random sleep time. // To fake iot devices are random intervals pick up sounds _rnd = new Random(); var sleepTime = _rnd.Next(10, 20); Thread.Sleep(sleepTime); var soundRecord = GetSoundLevel(); foreach (var sender in _senders) { sender.SendInfo(soundRecord); } } }
public async Task GivenTwoAddressesInDatabase_WhenIDelete_ItDeletesTheCorrectAddress() { var venue1 = GetNewVenue(); var venue2 = GetNewVenue(); using (var context = new DefaultContext(DbContextOptions)) { var venueRepository = new VenueRepository(context); venue1 = await venueRepository.CreateAsync(venue1); venue2 = await venueRepository.CreateAsync(venue2); List <VenueDb> allVenues = await context.Venues.ToListAsync(); Assert.AreEqual(2, allVenues.Count); } using (var context = new DefaultContext(DbContextOptions)) { var venueRepository = new VenueRepository(context); await venueRepository.DeleteAsync(venue2.Id); List <VenueDb> allVenues = await context.Venues.ToListAsync(); Assert.AreEqual(1, allVenues.Count); Assert.IsNull(await context.Venues.FindAsync(venue2.Id)); } }
public async Task RemoveVenue_Null_ThrowsArgumentException() { var options = new DbContextOptionsBuilder <BoboTuDbContext>() .UseInMemoryDatabase($"BoboTuDatabaseForTesting{Guid.NewGuid()}") .Options; var venueData = System.IO.File.ReadAllText(@"VenueDataSeed/venueDataSeed.json"); var venues = JsonConvert.DeserializeObject <List <Venue> >(venueData); int venueCount = 0; using (var context = new BoboTuDbContext(options)) { context.Venues.AddRange(venues); context.SaveChanges(); venueCount = context.Venues.Count(); } using (var context = new BoboTuDbContext(options)) { var venueRepo = new VenueRepository(context); await Assert.ThrowsAsync <ArgumentException>( // Act async() => { venueRepo.DeleteVenue(null); await venueRepo.SaveChanges(); } ); } }
public EditVenueModel(UserManager <Employee> userManager, RoleManager <EmployeeRole> roleManager, ICoordinatesService coordinates, CompanyRepository companies, VenueRepository venues, TagRepository tags, ImageRepository images, ISettings settings, DocumentRepository documents, VenueDocumentRepository venueDocuments, IMessagePublisher messagePublisher, Constants constants, ICryptoHelper cryptoHelper, VenueOpeningTimeRepository venueOpeningTimes) { this.coordinates = coordinates; this.userManager = userManager; this.roleManager = roleManager; this.venues = venues; this.tags = tags; this.images = images; this.settings = settings; this.documents = documents; this.venueDocuments = venueDocuments; this.companies = companies; this.messagePublisher = messagePublisher; this.constants = constants; this.cryptoHelper = cryptoHelper; this.venueOpeningTimes = venueOpeningTimes; }
public async Task RemoveVenueFromDb() { var options = new DbContextOptionsBuilder <BoboTuDbContext>() .UseInMemoryDatabase($"BoboTuDatabaseForTesting{Guid.NewGuid()}") .Options; var venueData = System.IO.File.ReadAllText(@"VenueDataSeed/venueDataSeed.json"); var venues = JsonConvert.DeserializeObject <List <Venue> >(venueData); int venueCount = 0; using (var context = new BoboTuDbContext(options)) { context.Venues.AddRange(venues); context.SaveChanges(); venueCount = context.Venues.Count(); } using (var context = new BoboTuDbContext(options)) { var venueRepo = new VenueRepository(context); var venue = (await venueRepo.GetAllVenuesAsync(new List <int>().ToArray(), new List <int>().ToArray())).First(); venueRepo.DeleteVenue(venue); await venueRepo.SaveChanges(); } using (var context = new BoboTuDbContext(options)) { var venueRepo = new VenueRepository(context); Assert.Equal(venueCount - 1, context.Venues.Count()); } }
public VenueModel(UserManager <Employee> userManager, RoleManager <EmployeeRole> roleManager, VenueRepository venues) { this.userManager = userManager; this.roleManager = roleManager; this.venues = venues; }
public MenuModel(UserManager <Employee> userManager, RoleManager <EmployeeRole> roleManager, VenueRepository venues, MenuRepository menus) { this.userManager = userManager; this.roleManager = roleManager; this.menus = menus; this.venues = venues; }
public VenueSyncConsumer( ILoggerFactory logger, ISettings settings, VenueRepository venues, Constants constants) : base(logger) { _settings = settings; _venues = venues; _constants = constants; }
public VenuesController() { _venueRepository = new VenueRepository(); _tablePackagesController = new TablePackagesController(); _beveragesController = new BeveragesController(); _venueHoursController = new VenueHoursController(); _tablesController = new TablesController(); _reservationsController = new ReservationsController(); _venueEmployeesController = new VenueEmployeesController(); }
public IActionResult GetUpcomingEvents(int venueId) { VenueRepository venueRepo = new VenueRepository(_context); var venue = _context.Venue.FirstOrDefault(v => v.VenueId == venueId); if (venue == null) { return(NotFound($"Venue '{venueId}' Not Found")); } return(new ObjectResult(venueRepo.GetEvents(venue))); }
public AddMenuModel(UserManager <Employee> userManager, RoleManager <EmployeeRole> roleManager, VenueRepository venues, MenuRepository menus, ProductRepository products) { this.userManager = userManager; this.roleManager = roleManager; this.menus = menus; this.venues = venues; this.products = products; }
public DataAccessService(string connectionString) { DataContext context = new DataContext(connectionString); Context = context; MessageRepository = new MessageRepository(context); NeedRepository = new NeedRepository(context); TagRepository = new TagRepository(context); VenueRepository = new VenueRepository(context); UserRepository = new UserRepository(context); WordRepository = new WordRepository(context); }
public AddEmployeeModel(UserManager <Employee> userManager, RoleManager <EmployeeRole> roleManager, VenueRepository venues, CompanyRepository companies, EmployeeRoleRepository roles) { this.userManager = userManager; this.roleManager = roleManager; this.venues = venues; this.roles = roles; this.companies = companies; }
public ProductModel(UserManager <Employee> userManager, RoleManager <EmployeeRole> roleManager, ProductTypeRepository productTypes, VenueRepository venues, ProductRepository products) { this.userManager = userManager; this.roleManager = roleManager; this.products = products; this.venues = venues; this.productTypes = productTypes; }
// public IUserDescriptionRepository UserDescriptions { get; } public UnitOfWork(ApplicationDbContext context) { _context = context; Gigs = new GigRepository(_context); Attendances = new AttendanceRepository(_context); Followings = new FollowingRepository(_context); Genres = new GenreRepository(_context); Venues = new VenueRepository(_context); UserNotifications = new UserNotificationRepository(_context); Users = new UserRepository(_context); Roles = new RoleRepository(_context); Logins = new LoginRepository(_context); // UserDescriptions = new UserDescriptionRepository(_context); }
public async void AddAsync_AddsToConext() { var venue = VenueGenerator.Create(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); var repository = new VenueRepository(context); await repository.AddAsync(venue); Assert.Equal(1, await context.Venue.CountAsync()); Assert.Equal(venue, await context.Venue.SingleAsync()); } }
public RegisterModel( UserManager <Employee> userManager, SignInManager <Employee> signInManager, ILogger <RegisterModel> logger, IEmailSender emailSender, CompanyRepository companies, VenueRepository venues) { _userManager = userManager; _signInManager = signInManager; _logger = logger; _emailSender = emailSender; this.companies = companies; this.venues = venues; }
public void DoesVenueExist_ChecksByName() { var venue = VenueGenerator.Create(); venue.VenueName = "King's College"; using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.Add(venue); context.SaveChanges(); var repository = new VenueRepository(context); Assert.True(repository.DoesVenueExist("King's College")); Assert.False(repository.DoesVenueExist("Queens's College")); } }
public async Task GivenTwoVenuesInDatabase_WhenIGetAll_ItReturns2Venues() { using (var context = new DefaultContext(DbContextOptions)) { var venueRepository = new VenueRepository(context); await venueRepository.CreateAsync(GetNewVenue()); await venueRepository.CreateAsync(GetNewVenue()); List <VenueDb> allVenues = await context.Venues.ToListAsync(); Assert.AreEqual(2, allVenues.Count); } }
public async Task GivenTwoAddressesInDatabase_WhenIGetById_ItReturnsTheCorrectAddress() { using (var context = new DefaultContext(DbContextOptions)) { var venueRepository = new VenueRepository(context); await venueRepository.CreateAsync(GetNewVenue()); await venueRepository.CreateAsync(GetNewVenue()); VenueDb venue = await context.Venues.FindAsync(2); Assert.AreEqual(2, venue.Id); }; }
public void VenueExists_ChecksById() { var venue = VenueGenerator.Create(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.Add(venue); context.SaveChanges(); var repository = new VenueRepository(context); Assert.True(repository.VenueExists(venue.VenueId)); Assert.False(repository.VenueExists(-1)); Console.WriteLine(venue.VenueId); } }
public async void DeleteAsync_RemovesFromContext() { var venue = VenueGenerator.Create(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.Add(venue); context.SaveChanges(); Assert.Equal(1, await context.Venue.CountAsync()); var repository = new VenueRepository(context); await repository.DeleteAsync(venue); Assert.Equal(0, await context.Venue.CountAsync()); } }
public async void GetByIdAsync_ReturnsCorrectItems() { var list = VenueGenerator.CreateList(5); var expected = list[2]; using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.AddRange(list); context.SaveChanges(); Assert.Equal(list.Count, await context.Venue.CountAsync()); var repository = new VenueRepository(context); var venue = await repository.GetByIdAsync(expected.VenueId); Assert.IsType <Venue>(venue); Assert.Equal(expected, venue); } }
public async void GetAllAsync_ReturnsAllFromContext() { var expectedVenues = VenueGenerator.CreateList(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.AddRange(expectedVenues); context.SaveChanges(); Assert.Equal(expectedVenues.Count, await context.Venue.CountAsync()); var repository = new VenueRepository(context); var resources = repository.GetAllAsync(); Assert.IsAssignableFrom <IQueryable <Venue> >(resources); Assert.Equal(expectedVenues, resources); } }
public async void UpdateAsync_UpdatesInContext() { var venue = VenueGenerator.Create(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.Add(venue); context.SaveChanges(); var repository = new VenueRepository(context); var newVenue = await repository.GetByIdAsync(venue.VenueId); newVenue.VenueName = "Old Sports Hall"; await repository.UpdateAsync(newVenue); Assert.Equal(1, await context.Venue.CountAsync()); Assert.Equal(newVenue, await context.Venue.SingleAsync()); } }
public async Task AddNewVenueToDb() { var options = new DbContextOptionsBuilder <BoboTuDbContext>() .UseInMemoryDatabase($"BoboTuDatabaseForTesting{Guid.NewGuid()}") .Options; var venueData = System.IO.File.ReadAllText(@"VenueDataSeed/venueDataSeed.json"); var venues = JsonConvert.DeserializeObject <List <Venue> >(venueData); int venueCount = 0; using (var context = new BoboTuDbContext(options)) { context.Venues.AddRange(venues); context.SaveChanges(); venueCount = context.Venues.Count(); } using (var context = new BoboTuDbContext(options)) { var venueRepo = new VenueRepository(context); var venue = new Venue() { AverageRating = 7.4, City = "Wrocław", Description = "Ładna restauracja" }; venueRepo.AddVenue(venue); await venueRepo.SaveChanges(); } using (var context = new BoboTuDbContext(options)) { var venueRepo = new VenueRepository(context); Assert.Equal(venueCount + 1, context.Venues.Count()); } }
public async Task GivenTwoAddressesInDatabase_WhenIUpdate_ItUpdatesTheCorrectAddress() { using (var context = new DefaultContext(DbContextOptions)) { var venueRepository = new VenueRepository(context); var venue1 = GetNewVenue(); var venue2 = GetNewVenue(); venue1 = await venueRepository.CreateAsync(venue1); venue2 = await venueRepository.CreateAsync(venue2); venue2.Name = "test update"; await venueRepository.UpdateAsync(venue2); var updatedVenue = await context.FindAsync <VenueDb>(venue2.Id); Assert.AreEqual(venue2.Name, updatedVenue.Name); Assert.AreEqual(venue2.Email, updatedVenue.Email); Assert.AreEqual(venue2.Phone, updatedVenue.Phone); Assert.AreEqual(venue2.Website, updatedVenue.Website); } }
public async Task GivenANewVenue_WhenICreateAVenue_ItCreatesAVenue() { using (var context = new DefaultContext(DbContextOptions)) { var venue = GetNewVenue(); var venueRepository = new VenueRepository(context); await venueRepository.CreateAsync(venue); List <VenueDb> allVenuesDb = await context.Venues.ToListAsync(); Assert.AreEqual(1, allVenuesDb.Count); Assert.AreEqual(1, allVenuesDb[0].Id); Assert.AreEqual(venue.Email, allVenuesDb[0].Email); Assert.AreEqual(venue.Website, allVenuesDb[0].Website); Assert.AreEqual(venue.Name, allVenuesDb[0].Name); Assert.AreEqual(venue.Phone, allVenuesDb[0].Phone); Assert.AreEqual(venue.VenueType, allVenuesDb[0].VenueType); Assert.AreEqual(venue.Address, allVenuesDb[0].Address); Assert.IsNotNull(venue.Address); Assert.IsNotNull(venue.createdDateUtc); Assert.IsNotNull(venue.modifiedDateUtc); } }
public VenueController(VenueRepository venues) { this.venues = venues; }
public VenueServices() { vanRepo = new VenueRepository(); }