public UnitOfWork(DbOptions opt) { DbContextOptions <HotelExamContext> options; Console.WriteLine(opt.Environment); // Connects to our in memory database if (opt.Environment == "Development") { options = new DbContextOptionsBuilder <HotelExamContext>() .UseInMemoryDatabase("InternalDb") .Options; } // Connects to our actual database else { options = new DbContextOptionsBuilder <HotelExamContext>() .UseSqlServer(opt.ConnectionString) .Options; } // Ensures that the database exsists context = new HotelExamContext(options); context.Database.EnsureCreated(); GuestRepository = new GuestRepository(context); AdminRepository = new AdminRepository(context); UserRepository = new UserRepository(context); BookingRepository = new BookingRepository(context); SingleRoomRepository = new SingleRoomRepository(context); DoubleRoomRepository = new DoubleRoomRepository(context); SuiteRepository = new SuiteRepository(context); }
public async Task CreateGuestAsync_CreatesGuest_IfGuestDtoCorrect() { // Arrange var mapperConfig = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>()); var mapper = mapperConfig.CreateMapper(); var options = await SetupTestDatabaseAsync(_guests); var httpContextAccessor = new Mock <IHttpContextAccessor>(); var guestRepository = new GuestRepository(new WeddingPlannerDbContext(options, httpContextAccessor.Object)); var guestService = new GuestService(mapper, guestRepository); // Act var guestDto = new GuestDto { FirstName = "John", LastName = "Doe" }; await guestService.CreateAsync(guestDto); // Assert using var context = new WeddingPlannerDbContext(options, httpContextAccessor.Object); var guests = await context.Guests.ToListAsync(); var guest = await context.Guests.SingleAsync(x => x.Id == 4); guest.Should().NotBeNull(); guest.Id.Should().Be(4); guest.FirstName.Should().Be("John"); guest.LastName.Should().Be("Doe"); }
public TestRepos() { //HotelManagementContext ss = new HotelManagementContext(); GuestRepository gg = new GuestRepository(); var test = gg.GetAll().ToList(); var test1 = test[0]; test1.PhoneNumber = "91199965"; gg.Update(test1); gg.Save(); //using (HotelManagementContext ss = new HotelManagementContext()) //{ // Persons = ss.Guests.ToList(); // Rooms = ss.Rooms.ToList(); // Reciepts = ss.Reciepts.ToList(); // Bills = ss.Bills.ToList(); // var person1 = Persons[2] as Guest; // var room1 = person1.BookedRooms[0]; // var person = ss.Guests.Single(x => x.Id == person1.Id); // var room = ss.Rooms.Single(x => x.Id == room1.Id); // ss.Entry(person).State= EntityState.Modified; // ss.Entry(room).State = EntityState.Modified; // room.MoveOut(); // //ss.Persons.Add(person); // //ss.Rooms.Add(room); // ss.SaveChanges(); // //ss.Bills.Add(new FoodBill(){Reciept = Reciepts.First(), Amount = 9999}); // //ss.SaveChanges(); // //Bills = ss.Bills.ToList(); //} }
/// <summary> /// Initializes a new instance of the <see cref="FactoryLogic"/> class. /// </summary> public FactoryLogic() { this.eventRepository = new EventRepository(this.eventDb); this.ticketRepository = new TicketRepository(this.eventDb); this.guestRepository = new GuestRepository(this.eventDb); this.adminUserRepository = new AdminUserRepository(this.eventDb); }
public DataAccessAction(ApplicationDbContext context) { _context = context; HotelRooms = new HotelRoomRepository(_context); Guests = new GuestRepository(_context); Reservations = new ReservationRepository(_context); ApplicationUsers = new ApplicationUserRepository(_context); }
public GuestController() { guestRepository = new GuestRepository(); config = new MapperConfiguration(cfg => { cfg.CreateMap <GuestRepository, GuestView>(); cfg.CreateMap <GuestView, GuestRepository>().ForMember(t => t.CreatedAt, opt => opt.UseValue(DateTime.Now)); }); mapper = config.CreateMapper(); }
/// <summary> /// Initializes a new instance of the <see cref="GuestRepositoryTest"/> class. /// </summary> public GuestRepositoryTest() { Common.Dependencies.Register(); DataAccess.Dependencies.Register(); this.applicationSetting = new ApplicationSetting(); this.applicationSetting.ShipServiceBaseAddress = "http://Localhost/"; DIContainer.Instance.Resolve<IApplicationSetting>().ReservationServiceBaseAddress = "http://locahost"; DIContainer.Instance.RegisterType<IReservationClient, ReservationClient>(); this.repository = new GuestRepository(); }
private void InsertGuest(UserView userView, int userID) { GuestRepository guestRepository = new GuestRepository(); guestRepository.CreatedAt = DateTime.Now; guestRepository.Quantity = userView.Quantity; guestRepository.UserName = userView.Name; guestRepository.UserID = userID; guestRepository.Insert(); }
public HotelRepository() { Guests = new GuestRepository(); Rooms = new RoomRepository(); Bills = new BillRepository(); RoomServices = new RoomServiceRepository(); Reciepts = new ReciptReposetory(); Employees = new EmployeeRepository(); ReceptionistValidation = new EmployeeValidationRepository(); }
public UnitOfWork(EasyHotelDbContext context) { this.context = context; Beds = new BedRepository(context); Rooms = new RoomRepository(context); RoomStates = new RoomStateRepository(context); RoomTypes = new RoomTypeRepository(context); Guests = new GuestRepository(context); Books = new BookRepository(context); }
public Booking(ReservationRepository reservationRepository, RoomRepository roomRepository, RoomPricesRepository roomPricesRepository, MealPlanRepository mealPlanRepository, MealPlanPricesRepository mealPlanPricesRepository, GuestRepository guestRepository) { _reservationRepository = reservationRepository; _roomRepository = roomRepository; _roomPricesRepository = roomPricesRepository; _mealPlanRepository = mealPlanRepository; _mealPlanPricesRepository = mealPlanPricesRepository; _guestRepository = guestRepository; }
public UnitOfWork(IDataService dataService) { _dataService = dataService; User = new UserRepository(_dataService); Company = new CompanyRepository(_dataService); Room = new RoomRepository(_dataService); StayType = new StayTypesRepository(_dataService); Guest = new GuestRepository(_dataService); Reservation = new ReservationRepository(_dataService); RoomReservation = new SchedulerRepository(_dataService); RoomReservationRepository = new RoomReservationRepository(_dataService); }
private void VerifyConfirm(List <UserView> model) { GuestRepository guestRepository = new GuestRepository(); var guests = guestRepository.GetAll(); foreach (var user in model) { if (guests.Exists(g => g.UserID == user.ID)) { user.Confirmed = true; } } }
public UnitOfWork( FarTrekDbContext context, IMapper mapper, IOptions <AppSettings> appSettings ) { _context = context; _mapper = mapper; _appSettings = appSettings; Users = new UserRepository(_appSettings, context, _mapper); Guests = new GuestRepository(context); Hotels = new HotelRepository(context); ReservationGuests = new ReservationGuestsRepository(context); Reservations = new ReservationRepository(context); Rooms = new RoomRepository(context); HotelRooms = new HotelRoomRepository(context); }
public GuestDTO[] GetGuests() { string connectionString = ConfigurationManager.ConnectionStrings["HotelDatabase"].ConnectionString; IGuestRepository repository = new GuestRepository(connectionString); var guests = repository.GetGuests(); var GuestDTOs = new List <GuestDTO>(); foreach (var guest in guests) { GuestDTOs.Add(new GuestDTO() { Id = guest.Id, Name = guest.Name, Surname = guest.Surname, Email = guest.Email, Phone = guest.Phone }); } return(GuestDTOs.ToArray()); }
public async Task GetGuestsAsync_ReturnsEmptyList_IfNoGuests() { // Arrange var mapperConfig = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>()); var mapper = mapperConfig.CreateMapper(); var options = await SetupTestDatabaseAsync(new List <Guest>()); var httpContextAccessor = new Mock <IHttpContextAccessor>(); var guestRepository = new GuestRepository(new WeddingPlannerDbContext(options, httpContextAccessor.Object)); var guestService = new GuestService(mapper, guestRepository); // Act var result = await guestService.GetGuestsAsync(); // Assert result.Should().NotBeNull(); result.Should().BeOfType <GuestListResponse>(); result.Item.Guests.Should().NotBeNull(); result.Item.Guests.Should().BeEmpty(); }
public async Task GetGuestsByAgeAsync_ReturnsGuests_WithAgeGreaterThanParam() { // Arrange int ageParam = 4; var mapperConfig = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>()); var mapper = mapperConfig.CreateMapper(); var options = await SetupTestDatabaseAsync(_guests); var httpContextAccessor = new Mock <IHttpContextAccessor>(); var guestRepository = new GuestRepository(new WeddingPlannerDbContext(options, httpContextAccessor.Object)); var guestService = new GuestService(mapper, guestRepository); // Act var result = await guestService.GetGuestsByAgeAsync(ageParam); // Assert result.Should().NotBeNull(); result.Should().BeOfType <GuestListResponse>(); result.Item.Guests.Should().NotBeNull(); result.Item.Guests.Should().HaveCount(2); }
private void ExecuteCreateUser() { if (!string.IsNullOrWhiteSpace(FirstName) && !string.IsNullOrWhiteSpace(Lastname) && !string.IsNullOrWhiteSpace(Phone) && DateOfBirth != default(DateTime)) { if (IsEdit) { Guest.FirstName = FirstName; Guest.Lastname = Lastname; Guest.PhoneNumber = Phone; Guest.Username = UserName; Guest.PasswordHash = PasswordHash; Guest.DateOfBirth = DateOfBirth; GuestRepository.Update(Guest); } else { Guest = new Guest { FirstName = FirstName, Lastname = Lastname, PhoneNumber = Phone, Username = UserName, PasswordHash = PasswordHash, DateOfBirth = DateOfBirth }; GuestRepository.Add(Guest); } GuestRepository.Save(); Messenger.Default.Send(new UpdateGuestMessage()); Messenger.Default.Send(new CloseDialogMessage()); } else { NotificationService.Warning("Validation error!", "You need to fill out all forms, except username and password"); } }
public FrontView() { Console.WriteLine("[1] Login:"******"[2] Register:"); int choice = Int32.Parse(Console.ReadLine()); InitialMenuEnum c = (InitialMenuEnum)choice; if (c == InitialMenuEnum.Login) { LoginView loginView = new LoginView(); loginView.Show(); } else if (c == InitialMenuEnum.Register) { GuestRepository guestRepository = new GuestRepository(); guestRepository.Add(); } else { Console.WriteLine("Invalid choice! Please try again!"); } }
public async Task GetGuestsByAgeAsync_ReturnsAdultPeople_IfNoGuestsAboveParam() { // Arrange int ageParam = 99; var mapperConfig = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>()); var mapper = mapperConfig.CreateMapper(); var options = await SetupTestDatabaseAsync(_guests); var httpContextAccessor = new Mock <IHttpContextAccessor>(); var guestRepository = new GuestRepository(new WeddingPlannerDbContext(options, httpContextAccessor.Object)); var guestService = new GuestService(mapper, guestRepository); // Act var result = await guestService.GetGuestsByAgeAsync(ageParam); // Assert result.Should().NotBeNull(); result.Should().BeOfType <GuestListResponse>(); result.Item.Guests.Should().NotBeNull(); result.Item.Guests.Should().HaveCount(1); result.Item.Guests.First().FirstName.Should().Be("Tom"); result.Item.Guests.First().LastName.Should().Be("Holland"); result.Item.Guests.First().Age.Should().Be(30); }
public static void EditGuest(int year, GuestModel guest) { GuestRepository.EditGuest(year, guest); }
public GuestController() { repo = new GuestRepository(); }
public GuestsController() { _guestRepo = new GuestRepository(); }
public GuestSearchViewModel(IGuestRepository guestRepository) : base(guestRepository) { Messenger.Default.Register <UpdateGuestMessage>(this, (x) => UpdateCollection(GuestRepository.GetAll().ToList())); UpdateCollection(GuestRepository.GetAll().ToList()); }
public ClientsForm() { InitializeComponent(); GuestRepository guestRepo = new GuestRepository(); }
public GuestLogic() { _guestRepo = new GuestRepository(); }
public static GuestModel GetGuest(int year, int guestId) { return(GuestRepository.GetGuest(year, guestId)); }
public HotelQuery(GuestRepository guestRepository, ReservationRepository reservationRepository, RoomRepository roomRepository) { Field <ListGraphType <RoomType> >("listGuests", resolve: context => { return(guestRepository.GetQuery().ToList()); } ); Field <ListGraphType <ReservationType> >("listReservations", resolve: context => { return(reservationRepository.GetQuery().ToList()); } ); Field <ListGraphType <RoomType> >("listRooms", resolve: context => { return(roomRepository.GetQuery().ToList()); } ); Field <ListGraphType <RoomType> >("searchRooms", arguments: new QueryArguments(new List <QueryArgument> { new QueryArgument <BooleanGraphType> { Name = "wifi" }, new QueryArgument <BooleanGraphType> { Name = "available" }, }), resolve: context => { var query = roomRepository.GetQuery(); var hasWifi = context.GetArgument <bool?>("wifi"); var available = context.GetArgument <bool?>("available"); if (hasWifi.HasValue) { query = query.Where(r => r.HasWifi == hasWifi.Value); } if (available.HasValue) { query = query.Where(r => r.Status == (available.Value ? RoomStatus.Available : RoomStatus.Unavailable)); } return(query.ToList()); } ); Field <RoomType>("getRoom", arguments: new QueryArguments(new List <QueryArgument> { new QueryArgument <IntGraphType> { Name = "id" }, }), resolve: context => { var query = roomRepository.GetQuery(); var id = context.GetArgument <int?>("id"); if (id.HasValue) { return(query.SingleOrDefault(r => r.Id == id.Value)); } return(null); } ); }
public static void AddGuest(int year, GuestModel guest) { GuestRepository.AddGuest(year, guest); }
public static void DeleteGuest(int year, int guestId) { GuestRepository.DeleteGuest(year, guestId); }
public GuestService(GuestRepository repository, IAccountService accountService) { this._repository = repository; this._accountService = accountService; }
public static List <GuestModel> GetGuests(int year) { return(GuestRepository.GetGuests(year).OrderBy(g => g.AccessCode).ToList()); }