public Mutation(HotelRepository hotelRepository) { Field <HotelType>("createHotel", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <CreateHotelCommandType> > { Name = "command" }), resolve: context => { var command = context.GetArgument <CreateHotelCommand>("command"); return(hotelRepository.AddHotel(command)); }); Field <HotelType>("addRoom", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <AddRoomCommandType> > { Name = "command" }), resolve: context => { var command = context.GetArgument <AddRoomCommand>("command"); var hotel = hotelRepository.GetById(command.HotelId); var newHotel = new Hotel(hotel.Id, hotel.Name, new List <Room>(hotel.Rooms) { command.Room }); return(hotelRepository.UpdateHotel(newHotel)); }); }
private static void Main() { using (var dataContext = new HotelDataContext()) { var cityRepository = new Repository <City>(dataContext); City city = cityRepository .SearchFor(c => c.Name.StartsWith("Paris")) .Single(); var hotelRepository = new HotelRepository(dataContext); IEnumerable <Hotel> orderedHotels = hotelRepository .FindHotelsByCity(city); Console.WriteLine("* Hotels in {0} *", city.Name); foreach (Hotel orderedHotel in orderedHotels) { Console.WriteLine(orderedHotel.Name); } Console.ReadKey(); } }
public UnitOfWork(DataContext session) { _session = session.OpenSession(); Endereco = new EnderecoRepository(_session); Hotel = new HotelRepository(_session); Quarto = new QuartoRepository(_session); }
private void ReloadPass(bool isNew = false) { if (isNew) { _hotelRepository = new HotelRepository(); _productRepository = new ProductRepository(); _isReload = true; } var passLimit = _hotelRepository.GetDailyPassLimit(_hotels.HotelId); CurrentPass.Text = passLimit.DailyPass.ToString(); HidPass.Value = passLimit.DailyPass.ToString(); CurrentCabana.Text = passLimit.CabanaPass.ToString(); HidCabana.Value = passLimit.CabanaPass.ToString(); CurrentSpa.Text = passLimit.SpaPass.ToString(); HidSpaPass.Value = passLimit.SpaPass.ToString(); CurrentDayBed.Text = passLimit.DaybedPass.ToString(); HidDayBed.Value = passLimit.DaybedPass.ToString(); var addOns = _productRepository.GetByHotelId(_hotels.HotelId, (int)Enums.ProductType.AddOns); RptAddOns.DataSource = addOns; RptAddOns.DataBind(); }
static void Main(string[] args) { var objContext = new SingleUsageObjectContextAdapter(new DbContextFactory <HotelAdminContext>()); var hotelRep = new HotelRepository(objContext); var factTypeRep = new FactTypeRepository(objContext); var historyRep = new DummyHistoryItemRepository(); FactTypeService factTypeService = new FactTypeService(objContext, factTypeRep); HotelService hotelService = new HotelService(objContext, hotelRep, historyRep); if (args != null && args.Length > 0 && args[0] == "world") { int numberOfHotels = 100; if (args.Length > 1) { if (!int.TryParse(args[1], out numberOfHotels)) { numberOfHotels = 100; // Default to 100 } } WorldLoader.LoadWorld(hotelService, factTypeService, numberOfHotels); return; } Console.WriteLine("Usage: HotelAdmin.Loader.exe {{world}} [maxItems] "); }
private static void Main() { using (var dataContext = new HotelDataContext()) { var cityRepository = new Repository<City>(dataContext); City city = cityRepository .SearchFor(c => c.Name.StartsWith("Paris")) .Single(); var hotelRepository = new HotelRepository(dataContext); IEnumerable<Hotel> orderedHotels = hotelRepository .FindHotelsByCity(city); Console.WriteLine("* Hotels in {0} *", city.Name); foreach (Hotel orderedHotel in orderedHotels) { Console.WriteLine(orderedHotel.Name); } Console.ReadKey(); } }
public void BookHotel(BookingSpecification bookingSpecification) { Hotel hotel = HotelRepository.GetById(bookingSpecification.HotelId); Customer costumer = CostumerRepository.GetById(bookingSpecification.CostumerId); hotel.Book(costumer, bookingSpecification.Dates); }
public void EntersRewardCustomerGetsCheapestBestRatedHotel() { HotelRepository expected = new HotelRepository(140, "Ridgewood", 5); HotelRepository actual = hotel.GetCheapestHotel("Reward", "11Sep2020", "12Sep2020"); expected.Equals(actual); }
// GET: Hotels public ActionResult Index() { HotelRepository hotel = new HotelRepository(); var list = hotel.showHotels(); return(View(list)); }
public void EnterRegularCustomerGetsCheapestBestRatedHotel() { HotelRepository expected = new HotelRepository(200, "Bridgewood", 4); HotelRepository actual = hotel.GetCheapestHotel("Regular", "11Sep2020", "12Sep2020"); expected.Equals(actual); }
public async Task Book_Room_Request_Can_Be_Accepted_After_Decline_Size_3() { IHotelRepository repo = new HotelRepository(3); IBookingDataAdapter data = new BookingDataAdapter(repo, new BookingProcessor(repo)); BookingController controller = new BookingController(data); List <Tuple <int, int> > list = new List <Tuple <int, int> >(); list.Add(new Tuple <int, int>(1, 3)); list.Add(new Tuple <int, int>(0, 15)); list.Add(new Tuple <int, int>(1, 9)); foreach (var request in list) { var response = await controller.BookFirstAvailableRoom(request.Item1, request.Item2); Assert.AreEqual(((ObjectResult)response).StatusCode, 201); } var badResponse = await controller.BookFirstAvailableRoom(2, 5); Assert.AreEqual(((ObjectResult)badResponse).StatusCode, 400); var createdResponse = await controller.BookFirstAvailableRoom(4, 9); Assert.AreEqual(((ObjectResult)createdResponse).StatusCode, 201); }
/// <summary> /// 构造函数 /// </summary> /// <param name="shop"></param> /// <param name="channel"></param> public MeiTuanProductChannel(ShopType shop, ProductChannel channel) { Channel = channel; Shop = shop; meituanRepository = new MeiTuanRepository(); hotelRepository = new HotelRepository(channel); MeiTuanConfig config = new MeiTuanConfig(); if (Shop == ShopType.LingZhong || Shop == ShopType.YinJi || Shop == ShopType.RenXing) { config = MeiTuanConfigManager.XiWan; } else if (Shop == ShopType.ShengLv) { config = MeiTuanConfigManager.ShengLv; } else if (Shop == ShopType.RenNiXing) { config = MeiTuanConfigManager.RenNiXing; } meiTuanApiClient = new MeiTuanApiClient(config); logWriter = new LogWriter("Tmall/Validate"); }
public async Task Book_Room_Complex_Requests_Size_2() { IHotelRepository repo = new HotelRepository(2); IBookingDataAdapter data = new BookingDataAdapter(repo, new BookingProcessor(repo)); BookingController controller = new BookingController(data); List <Tuple <int, int, int> > list = new List <Tuple <int, int, int> >(); list.Add(new Tuple <int, int, int>(1, 3, 201)); list.Add(new Tuple <int, int, int>(0, 4, 201)); list.Add(new Tuple <int, int, int>(2, 3, 400)); list.Add(new Tuple <int, int, int>(5, 5, 201)); list.Add(new Tuple <int, int, int>(4, 10, 201)); list.Add(new Tuple <int, int, int>(10, 10, 201)); list.Add(new Tuple <int, int, int>(6, 7, 201)); list.Add(new Tuple <int, int, int>(8, 10, 400)); list.Add(new Tuple <int, int, int>(8, 9, 201)); foreach (var request in list) { var response = await controller.BookFirstAvailableRoom(request.Item1, request.Item2); Assert.AreEqual(((ObjectResult)response).StatusCode, request.Item3); } }
public async Task Book_Room_Complex_Requests_Size_2() { IHotelRepository repo = new HotelRepository(2); IBookingProcessor processor = new BookingProcessor(repo); List <Tuple <int, int, bool> > list = new List <Tuple <int, int, bool> >(); list.Add(new Tuple <int, int, bool>(1, 3, true)); list.Add(new Tuple <int, int, bool>(0, 4, true)); list.Add(new Tuple <int, int, bool>(2, 3, false)); list.Add(new Tuple <int, int, bool>(5, 5, true)); list.Add(new Tuple <int, int, bool>(4, 10, true)); list.Add(new Tuple <int, int, bool>(10, 10, true)); list.Add(new Tuple <int, int, bool>(6, 7, true)); list.Add(new Tuple <int, int, bool>(8, 10, false)); list.Add(new Tuple <int, int, bool>(8, 9, true)); foreach (var request in list) { try { await processor.BookFirstAvailableRoomAsync(new Reservation { StartDay = request.Item1, EndDay = request.Item2 }); Assert.IsTrue(request.Item3); } catch (Exception) { Assert.IsFalse(request.Item3); } } }
public async Task Book_Room_Request_Are_Declined_Size_3() { IHotelRepository repo = new HotelRepository(3); IBookingProcessor processor = new BookingProcessor(repo); List <Tuple <int, int> > list = new List <Tuple <int, int> >(); list.Add(new Tuple <int, int>(1, 3)); list.Add(new Tuple <int, int>(3, 5)); list.Add(new Tuple <int, int>(1, 9)); foreach (var request in list) { try { await processor.BookFirstAvailableRoomAsync(new Reservation { StartDay = request.Item1, EndDay = request.Item2 }); Assert.IsTrue(true); } catch (Exception) { Assert.Fail(); } } try { await processor.BookFirstAvailableRoomAsync(new Reservation { StartDay = 0, EndDay = 15 }); Assert.Fail(); } catch (Exception) { Assert.IsTrue(true); } }
/* CategoriaRepository categoriaRepository = new CategoriaRepository(); * List<Categoria> categorias = categoriaRepository.ObterTodos(); * ViewBag.Categorias = categorias; */ public ActionResult Cadastro() { HotelRepository hotelRepository = new HotelRepository(); List <Hotel> hoteis = hotelRepository.ObterTodos(); ViewBag.Hoteis = hoteis; return(View()); }
public ActionResult Blumenau() { HotelRepository hotelRepository = new HotelRepository(); List <Hotel> hoteis = hotelRepository.ObterTodosPelaCidade("Blumenau"); ViewBag.Hoteis = hoteis; return(View()); }
public ReservationController() { this.sortieParSemaineRepository = new Excursion.Business.Repositories.SortieParSemaineRepository(new ExcursionContext()); this.reservationRepository = new ReservationRepository(new ExcursionContext()); this.hotelRepository = new HotelRepository(new ExcursionContext()); this.langueRepository = new LangueRepository(new ExcursionContext()); this.userRepository = new UserRepository(new ExcursionContext()); }
public int GetHotelId(string hotelName) { string connectionString = ConfigurationManager.ConnectionStrings["HotelServiceDB"].ConnectionString; IHotelRepository repository = new HotelRepository(connectionString); int hotelId = repository.HotelId(hotelName); return(hotelId); }
private void InitializeRepositories() { arrangementRepository = RepositoryFactory.RepositoryFactory.GetArrangementRepository(); destinationRepository = RepositoryFactory.RepositoryFactory.GetDestinationRepository(); hotelRepository = RepositoryFactory.RepositoryFactory.GetHotelRepository(); reservationRepository = RepositoryFactory.RepositoryFactory.GetReservationRepository(); adminRepository = RepositoryFactory.RepositoryFactory.GetUserRepository(); customerRepository = RepositoryFactory.RepositoryFactory.GetCustomerRepository(); }
private void SaveHotel(object sender, RoutedEventArgs e) { M120Entities m120Entities = new M120Entities(); List <Land> countriesList = m120Entities.Lands.ToList(); HotelRepository hotelRepository = new HotelRepository(); HotelImageRepository imageRepository = new HotelImageRepository(); hotelRepository.addHotel(hotelNametxtbox.Text, hotelPlacetxtbox.Text, countriesList.Find(x => x.Name == hotelCountrycombobox.SelectedValue).Name, Int16.Parse(hotelRatingtxtbox.Text), hotelManagertxtbox.Text, Int16.Parse(hotelAmountofRoomstxtbox.Text), Int16.Parse(hotelPricePerDaytxtbox.Text), hotelPhonetxtbox.Text, hotelEmailtxtbox.Text, hotelWebtxtbox.Text, imageRepository.SaveImageToByte(HotelImage), ImageDescription.Text); }
public void EntersWrongCustomerTypeThrowsException() { try { HotelRepository result = hotel.GetCheapestHotel("Special", "11Sep2020", "12Sep2020"); } catch (HotelReservationCustomException exception) { Assert.AreEqual(exception.Message, "No such customer type"); } }
public CtripProductChannel(ShopType shopType) { ctripApiClient = new CtripApiClient(Ctrip.Config.ApiConfigManager.ChenYi); this.Shop = shopType; ctripRepository = new CtripRepository(); hotelRepository = new HotelRepository(ProductChannel.Ctrip); logWriter = new LogWriter("Tmall/Validate"); }
public async Task Book_Room_Outside_Of_Planning_Period_Year_Size_1() { IHotelRepository repo = new HotelRepository(1); IBookingDataAdapter data = new BookingDataAdapter(repo, new BookingProcessor(repo)); BookingController controller = new BookingController(data); var response = await controller.BookFirstAvailableRoom(200, 400); Assert.AreEqual(((ObjectResult)response).StatusCode, 400); }
public ActionResult Index() { //Just to initialise the DB. HotelRepository hotel = new HotelRepository(); var list = hotel.showHotels(); ViewBag.Title = "Home Page"; return(View()); }
public ReservationsTab(Model model) { this.model = model; ListOfClients = model.SearchedClients; ListOfHotels = HotelRepository.GetHotels(); ListOfReservations = model.Reservations; ListOfRooms = model.Rooms; StartDate = DateTime.Today; EndDate = DateTime.Today; }
private void BindPolicies(bool isReload = false) { if (isReload) { _hotelRepository = new HotelRepository(); } var policies = _hotelRepository.GetAllPolices(); RptPoliciesListing.DataSource = policies; RptPoliciesListing.DataBind(); }
public async System.Threading.Tasks.Task TestHotelprocessorGetHotelByMhidAsync() { var Actualdata = ReadJsondata(); IHotelRepository _repository = new HotelRepository(_dbcontext); IHotelProcessor _processor = new HotelProcessor(_repository); var controller = new HotelController(_processor); var response = _processor.GetHotelByMhid(1); Assert.AreEqual(response.Model.Name.ToLower(), Actualdata.model.name.ToLower()); }
public async Task HotelService_Filter_ShouldReturnHotelNull() { //Arrange var hotelRepository = new HotelRepository(); var hotelService = new HotelService(hotelRepository); //Act var result = await hotelService.Filter(1, new DateTime(2016, 03, 15)); //Assert Assert.AreEqual(result, null); }
public async Task HotelService_Filter_ShouldReturnHotelRatesCountZero() { //Arrage var hotelRepository = new HotelRepository(); var hotelService = new HotelService(hotelRepository); //Act var result = await hotelService.Filter(7294, new DateTime()); //Assert Assert.AreEqual(result.HotelRates.Count, 0); }
public async Task HotelService_Filter_ShouldReturnCorrectData() { //Arrage var hotelRepository = new HotelRepository(); var hotelService = new HotelService(hotelRepository); //Act var result = await hotelService.Filter(7294, new DateTime(2016, 03, 15)); //Assert Assert.AreEqual(result.Hotel.HotelID, 7294); }
public HotelDTO[] GetHotels() { IHotelRepository repository = new HotelRepository(this._connStrBuilder.ConnectionString); var hotels = repository.GetHotels(); var hotelsDTOs = new List<HotelDTO>(); foreach (var hotel in hotels) { hotelsDTOs.Add(new HotelDTO() { id = hotel.id, name = hotel.name, address = hotel.address }); } return hotelsDTOs.ToArray(); }
static void Main(string[] args) { var objContext = new SingleUsageObjectContextAdapter(new DbContextFactory<HotelAdminContext>()); var hotelRep = new HotelRepository(objContext); var factTypeRep = new FactTypeRepository(objContext); var historyRep = new DummyHistoryItemRepository(); FactTypeService factTypeService = new FactTypeService(objContext, factTypeRep); HotelService hotelService = new HotelService(objContext, hotelRep, historyRep); if (args != null && args.Length > 0 && args[0] == "world") { int numberOfHotels = 100; if (args.Length > 1) { if (!int.TryParse(args[1], out numberOfHotels)) numberOfHotels = 100; // Default to 100 } WorldLoader.LoadWorld(hotelService, factTypeService, numberOfHotels); return; } Console.WriteLine("Usage: HotelAdmin.Loader.exe {{world}} [maxItems] "); }
public List<Hotel> GetHotelsforUpdate() { HotelRepository hr = new HotelRepository(); return hr.GetHotels(); }