public void ShouldWorkWithCorrectId() { var autoMapperConfig = new AutoMapperConfig(); autoMapperConfig.Execute(typeof(DetailsController).Assembly); var hotelServiceMock = new Mock<IHotelsService>(); Hotel hotelForTest = new Hotel() { Id = 1, Name = "Some name", Description = "Some description", Location = new Location() { Country = "Bulgaria", City = "Sofia", Address = "5th Street" }, Email = "*****@*****.**", Stars = 4 }; hotelServiceMock.Setup(x => x.GetById(It.IsAny<int>())) .Returns(hotelForTest); var hotelRoomsServiceMock = new Mock<IHotelRoomsService>(); hotelRoomsServiceMock.Setup(x => x.GetUniqueRoomTypesInHotel(It.IsAny<int>())) .Returns(new List<HotelRoom>().AsQueryable()); var controller = new DetailsController(hotelServiceMock.Object, hotelRoomsServiceMock.Object); var id = 1; controller.WithCallTo(x => x.HotelDetails(id)) .ShouldRenderView("HotelDetails") .WithModel<DetailsViewModel>( viewModel => { Assert.AreEqual(hotelForTest, viewModel.Hotel); }).AndModelError(""); }
public Trip(DateTime startDate, DateTime endDate, Destination destination, Hotel hotel) { StartDate = startDate; EndDate = endDate; Destination = destination; Hotel = hotel; }
public int Insert(Hotel hotel) { hotelContext.Hotels.Add(hotel); Save(); return hotel.ID; }
private SearchResultHotel(Hotel hotel, IEnumerable<SearchResultRoom> searchResultRooms, DateTime arrival, DateTime departure) { HotelId = hotel.Id; Arrival = arrival; Departure = departure; Name = hotel.Name; PhoneNumber = hotel.Phone; Email = hotel.Email; Address = hotel.Address1 + " " + hotel.Address2; City = hotel.City; Zipcode = hotel.Zipcode; Country = hotel.Country; About = hotel.About.GetText(LanguageTypeEnum.English); CheckIn = hotel.CheckIn + " " + hotel.CheckInAMPM; CheckOut = hotel.CheckOut + " " + hotel.CheckOutAMPM; MinimumStay = hotel.MinimumStay; MinimumCheckInAge = hotel.MinimumCheckInAge; Amenities = hotel.Amenities.Select(x => x.Name); Rooms = searchResultRooms; Photos = hotel.Assets.Select(x => x.GenerateUrl(580, 358) + x.GenerateCroppingQuery()); Thumbnails = hotel.Assets.Select(x => x.GenerateUrl(77, 44) + x.GenerateCroppingQuery()); }
public HotelMod(int idHotel) { InitializeComponent(); hotel = DAOHotel.obtener(idHotel); regimen_hotel = DAORegimen.obtenerByHotel(idHotel); regimenes = DAORegimen.obtenerTodos(); }
public IHttpActionResult PutHotel(int id, Hotel hotel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != hotel.Hotel_No) { return BadRequest(); } db.Entry(hotel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HotelExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
/// <summary> /// Get hotels in area, use Geo search /// </summary> /// <param name="hotel"></param> /// <param name="kilometers"></param> /// <param name="number"></param> /// <returns></returns> public IEnumerable<SearchResultItem> GetHotelsInArea(Hotel hotel, int kilometers, int number) { var search = _client.Search<Hotel>() .Filter(h => h.GeoCoordinates.WithinDistanceFrom(hotel.GeoCoordinates, kilometers.Kilometers())); return search.Take(number).GetResult().Select(_searchResultItemBuilder.FromHotel); }
public async void UpdateHotel(Hotel hotelToUpdate) { var response = await PersistencyClass.UpdateHotel(hotelToUpdate); await Task.Delay(100); if (response != null) { LoadHotels(); } }
public async void PostHotel(Hotel hotelToPost) { var response = await PersistencyClass.PostHotelToDb(hotelToPost); await Task.Delay(100); if (response != null) { LoadHotels(); } }
public async void DeleteHotel(Hotel selectedHotel) { var response = await PersistencyClass.DeleteHotel(selectedHotel); await Task.Delay(100); if (response != null) { Hotels.Remove(selectedHotel); } }
public ActionResult Insert(Hotel hotel) { if (ModelState.IsValid) { hotelRepository.Save(hotel); return RedirectToAction("List"); } return View(hotel); }
// END CUT HERE // BEGIN CUT HERE public static void Main() { try { Hotel ___test = new Hotel(); ___test.run_test(-1); } catch(Exception e) { //Console.WriteLine(e.StackTrace); Console.WriteLine(e.ToString()); } }
/// <summary> /// Get facility by id /// </summary> /// <param name="hotel"></param> /// <returns></returns> public IEnumerable<Facility> GetFacilitiesForHotel(Hotel hotel) { var facilities = Facilities; foreach (var facility in facilities) { facility.IsSelected = hotel.Features.Any( f => f.Equals(facility.Value, StringComparison.InvariantCultureIgnoreCase)); } return facilities; }
public IHttpActionResult PostHotel(Hotel hotel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Hotels.Add(hotel); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = hotel.Hotel_No }, hotel); }
public void CanMapToDTO() { var model = new Hotel{Id = 1, Name="Test", SingleRoomPrice = 100, DoubleRoomPrice = 200, TripleRoomPrice = 300, GroupRoomPrice = 400, ExtraBedPrice = 500, IsActive = true}; var result = _subject.ToDTO(model); Assert.That(result.Id, Is.EqualTo(1)); Assert.That(result.Name, Is.EqualTo("Test")); Assert.That(result.SingleRoomPrice, Is.EqualTo(100)); Assert.That(result.DoubleRoomPrice, Is.EqualTo(200)); Assert.That(result.TripleRoomPrice, Is.EqualTo(300)); Assert.That(result.GroupRoomPrice, Is.EqualTo(400)); Assert.That(result.ExtraBedPrice, Is.EqualTo(500)); Assert.That(result.IsActive, Is.EqualTo(true)); }
public BookingsGUI(int Hid) { InitializeComponent(); this.Hid = Hid; hotel = this.serv.HotelInfo(this.Hid); info_hid.Content = hotel.Hid; info_name.Content = hotel.Name; info_adr.Content = hotel.Adr; this.reloadBtn_Click(null, null); }
public RegistrarIngresoEgreso(Usuario user, Reserva reserv, ModoApertura modoApert, Hotel hotelSelecc) { InitializeComponent(); usuario = user; reserva = reserv; modoApertura = modoApert; hotelSeleccionado = hotelSelecc; precio = 0; PopularGrillas(); ModificarBotonesSegunTipoRegistro(); if (ModoApertura.CHECKIN == modoApertura) MessageBox.Show("Recuerde ingresar los datos de todos los huéspedes.", "Atención", MessageBoxButtons.OK); }
public GenerarReserva(Usuario user, Hotel hotelSeleccionado) : this() { hotel = hotelSeleccionado; usuario = user; PopularComboBoxesYGrillas(); if (usuario.tipo != "CLIENTE" & usuario.tipo != "GUEST") { this.hotelComboBox.SelectedItem = this.BuscarHotelRecepcionista(); this.hotelComboBox.Refresh(); this.hotelComboBox.Enabled = false; } }
public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel) { string newHotelName = FilterPunctuation(supplierHotel.Name); string newAddress = FilterPunctuation(supplierHotel.Address); if (newHotelName == hotel.Name && newAddress == hotel.Address) { return true; } else { return false; } }
public void SendReservationEmailToCustomer(Hotel hotel, Reservation reservation) { dynamic email = SendGridEmailService.CreateEmail("reservation_confirmation_hotel_html"); email.Hotel = hotel; email.Reservation = reservation; var message = SendGridEmailService.RenderEmail(email); message.From = new MailAddress(hotel.Email); message.AddTo(reservation.Email); message.Subject = "Your reservation at " + hotel.Name; SendGridEmailService.Send(message); }
public bool IsMatch(SupplierHotel supplierHotel, Hotel hotel) { string[] names = supplierHotel.Name.Split(new char[] {' '}); Array.Reverse(names); StringBuilder sb = new StringBuilder(); foreach (var item in names) { sb.Append(item); sb.Append(" "); } string result = sb.ToString(); result = result.TrimEnd(); return (result == hotel.Name) ? true : false; }
public void SendPasswordChangedEmailToUser(User user, string password, Hotel hotel) { dynamic template = SendGridEmailService.CreateEmail("admin_user_password_changed_html"); template.User = user; template.Password = password; template.Hotel = hotel; var message = SendGridEmailService.RenderEmail(template); message.From = new MailAddress(hotel.Email, hotel.Name, Encoding.UTF8); message.AddTo(user.Email); message.Subject = "Your password has been changed"; SendGridEmailService.Send(message); }
public void Types() { Assert.IsTrue(typeof(IRoom).IsInterface); var r = new Room(35.0, RoomStandard.Apartment); Assert.IsTrue(typeof(Room).GetInterfaces().Contains(typeof(IRoom))); Assert.AreEqual(35.0, (r as IRoom).SquareMeters); Assert.IsTrue(typeof(IHotel).IsInterface); Assert.IsTrue(typeof(Hotel<Room, SquareMetersComparer>).GetInterfaces().Contains(typeof(IHotel))); var h = new Hotel<Room, SquareMetersComparer>(5, r); Assert.AreEqual((uint)5, (h as IHotel).Stars); Assert.IsTrue(typeof(SquareMetersComparer).GetInterfaces().Contains(typeof(IComparer<Room>))); Assert.IsTrue(typeof(StandardMultipliedSquareMetersComparer).GetInterfaces().Contains(typeof(IComparer<Room>))); Assert.AreEqual(typeof(SquareMetersComparer).BaseType, typeof(StandardMultipliedSquareMetersComparer).BaseType); Assert.AreNotEqual(typeof(SquareMetersComparer).BaseType, typeof(object)); Assert.AreNotEqual(typeof(SquareMetersComparer).BaseType, typeof(ValueType)); Assert.IsTrue(typeof(SquareMetersComparer).BaseType.IsAbstract); Assert.AreNotEqual(typeof(SquareMetersComparer).BaseType, typeof(Comparer<Room>)); }
/// <summary> /// Get SearchResultItem from Hotel class /// </summary> /// <param name="h"></param> /// <returns></returns> public SearchResultItem FromHotel(Hotel h) { var shortLocation = h.FullAddress; // Just use a short location (not the ShortLocation property because it sometimes only shows the street and number) // description, unfortunately some times the Location object don't have city but a Province. if (h.Location != null) { shortLocation = string.Format("{0}, {1}", h.Location.Title, h.Location.Country.Title); } return new SearchResultItem { Id = h.Id, Title = h.Title, Location = shortLocation, Price = h.PriceUSD, StarRating = h.StarRating, Image = _hotelImageUtils.GetHotelImage(h.Images, _searchResultsImageWidth, _searchResultsImageHeight) }; }
public HotelDTO ToDTO(Hotel model) { try { return new HotelDTO { Id = model.Id, Name = model.Name, SingleRoomPrice = model.SingleRoomPrice, DoubleRoomPrice = model.DoubleRoomPrice, TripleRoomPrice = model.TripleRoomPrice, GroupRoomPrice = model.GroupRoomPrice, ExtraBedPrice = model.ExtraBedPrice, IsActive = model.IsActive }; } catch (Exception) { throw new Exception("Error occured when mapping hotel service model to DTO: " + model.Name); } }
private void ReadHotels(int n) { int iCounter = 0; while (iCounter < n) { string[] hotelData = Console.ReadLine().Split(' '); int iFacilities = 2; Hotel hotel = new Hotel(); hotel.Id = Int32.Parse(hotelData[0]); hotel.AveragePrice = Int32.Parse(hotelData[1]); while (iFacilities < hotelData.Length) { hotel.Facilities.Add(hotelData[iFacilities]); iFacilities++; } _lstHotels.Add(hotel); iCounter++; } }
public ModificarReserva(Usuario user, Reserva reserve, Hotel hotelSelec) { InitializeComponent(); usuario = user; reserva = reserve; hotel = hotelSelec; habitacionesRemovidas = new List<Habitacion>(); habitacionesAgregadas = new List<Habitacion>(); contador = 1; PopularComboBoxesYGrillas(); this.hotelComboBox.SelectedItem = this.BuscarHotelReserva(); this.hotelComboBox.Enabled = false; this.PopularRegimen(); CalcularPrecioHabitaciones(this.HabitacionesReservadasDataGrid); CalcularPrecioHabitaciones(this.HabitacionesDisponiblesDataGrid); if (habitacionesDisponibles.Count == 0) MessageBox.Show("No hay habitaciones disponibles para la fecha de la reserva.", "Atención", MessageBoxButtons.OK); }
public void SaveHotel(Hotel hotel) { if (hotel.Id == 0) { Db.Hotels.Add(hotel); } else { Hotel dbEntry = Db.Hotels.Find(hotel.Id); if (dbEntry != null) { dbEntry.HotelName = hotel.HotelName; dbEntry.Address = hotel.Address; dbEntry.Category = hotel.Category; dbEntry.DayPrice = hotel.DayPrice; dbEntry.Desctirption = hotel.Desctirption; dbEntry.X = hotel.X; dbEntry.Y = hotel.Y; } } Db.SaveChanges(); }
public IEnumerable<RoomTypeInventory> EnsureInventories(Hotel hotel, IEnumerable<RoomTypeInventory> inventories, int year, int month) { var daysInMonth = DateTime.DaysInMonth(year, month); var startDate = new DateTime(year, month, 1); var endDate = new DateTime(year, month, daysInMonth); var dates = CalendarService.FindAllDaysInMonthBy(year, month); var reservations = ReservationService.FindBy(hotel.Id, startDate, endDate); var reservationItems = reservations.SelectMany(x => x.Items); var roomtypes = hotel.RoomTypes; var result = new List<RoomTypeInventory>(); for (var i = 1; i <= daysInMonth; i++) { var date = dates.First(x => x.Value.Day == i); foreach (var roomType in roomtypes) { var reservationsItemsForRoomtype = reservationItems.Where(x => x.RoomTypeId == roomType.Id); var numberOfReservations = reservationsItemsForRoomtype.SelectMany(x => x.PricePerDate).Count(x => x.Date.Day == i); if (!inventories.Any(x => x.RoomTypeId == roomType.Id && x.Date.Value.Day == i)) { var inventory = RoomTypeInventory.Create(roomType.Id, date); // Available Quantity inventory.Quantity = roomType.Quantity + numberOfReservations; result.Add(inventory); } } } return result; }
public static async Task<HttpResponseMessage> DeleteHotel(Hotel hotelToDelete) { using (var client = new HttpClient(GetHandler())) { SetClientSettingsToJson(client); try { var response = await client.DeleteAsync("api/Hotels/" + hotelToDelete.Hotel_No); if (!response.IsSuccessStatusCode) { throw new ArgumentException(response.StatusCode.ToString()); } return response; } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } return null; } }
public async Task UpdateHotelAsync(Hotel hotel) { _context.Hotel.Update(hotel); await _context.SaveChangesAsync(); }
public Vocation(DateTime startDate, DateTime endDateTime, Hotel hotel) { _startDate = startDate; _endDateTime = endDateTime; _hotel = hotel; }
public async Task UpdateInfo(Hotel hotelInfo) { _hotel.State = hotelInfo; await _hotel.WriteStateAsync(); }
public async static Task UpdateHotelInQuantity(string id, string type, string ope) { if (!await Initialize()) { return; } Hotel hotel = new Hotel(); var hotelList = new List <Hotel>(); var itemQuery = docClient.CreateDocumentQuery <Hotel>( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true }) .Where(hotel => hotel.Id == id) .AsDocumentQuery(); while (itemQuery.HasMoreResults) { var queryResult = await itemQuery.ExecuteNextAsync <Hotel>(); hotelList.AddRange(queryResult); } hotel = hotelList[0]; if (type == "Double") { if (ope == "+") { hotel.doubleroom++; } else { hotel.doubleroom--; } } else if (type == "Quadruple") { if (ope == "+") { hotel.Quaroom++; } else { hotel.Quaroom--; } } else if (type == "Suite") { if (ope == "+") { hotel.suit++; } else { hotel.suit--; } } else { return; } var docUri = UriFactory.CreateDocumentUri(databaseName, collectionName, hotel.Id); await docClient.ReplaceDocumentAsync(docUri, hotel); }
public async Task <IActionResult> Post([FromBody] Hotel hotel) { var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", routeValues: new { id = createdHotel.Id }, createdHotel)); // 201+data }
static void Main(string[] args) { int hotelNumber = int.Parse(Console.ReadLine()); List <Hotel> hotels = new List <Hotel>(); while (hotelNumber-- > 0) { string[] hotelRestrictions = Console.ReadLine().Split(' '); Hotel hotel = new Hotel(); hotel.facilities = new List <string>(); hotel.id = int.Parse(hotelRestrictions[0]); hotel.cost = int.Parse(hotelRestrictions[1]); for (int i = 2; i < hotelRestrictions.Length; i++) { hotel.facilities.Add(hotelRestrictions[i]); } hotels.Add(hotel); } int testNumber = int.Parse(Console.ReadLine()); while (testNumber-- > 0) { string[] clientInput = Console.ReadLine().Split(' '); int clientCost = int.Parse(clientInput[0]); List <string> clientFacilities = new List <string>(); for (int i = 1; i < clientInput.Length; i++) { clientFacilities.Add(clientInput[i]); } List <Hotel> goodHotels = new List <Hotel>(); foreach (Hotel hotel in hotels) { if (clientCost >= hotel.cost) { bool isGood = true; foreach (string facility in clientFacilities) { if (!hotel.facilities.Contains(facility)) { isGood = false; break; } } if (isGood) { goodHotels.Add(hotel); } } } for (int i = 0; i < goodHotels.Count - 1; i++) { for (int j = i + 1; j < goodHotels.Count; j++) { if (goodHotels[i].facilities.Count < goodHotels[j].facilities.Count) { Hotel tmp = goodHotels[i]; goodHotels[i] = goodHotels[j]; goodHotels[j] = tmp; } } } for (int i = 0; i < goodHotels.Count - 1; i++) { for (int j = i + 1; j < goodHotels.Count; j++) { if (goodHotels[i].facilities.Count == goodHotels[j].facilities.Count) { if (goodHotels[i].cost > goodHotels[j].cost) { Hotel tmp = goodHotels[i]; goodHotels[i] = goodHotels[j]; goodHotels[j] = tmp; } } } } for (int i = 0; i < goodHotels.Count - 1; i++) { for (int j = i + 1; j < goodHotels.Count; j++) { if (goodHotels[i].facilities.Count == goodHotels[j].facilities.Count) { if (goodHotels[i].cost == goodHotels[j].cost) { if (goodHotels[i].id > goodHotels[j].id) { Hotel tmp = goodHotels[i]; goodHotels[i] = goodHotels[j]; goodHotels[j] = tmp; } } } } } foreach (Hotel hotel in goodHotels) { Console.Write(hotel.id + " "); } Console.WriteLine(); } }
public int Insert(Hotel hotel) { throw new NotImplementedException(); }
protected override void Seed(HotelService.Data.HotelAppContext context) { Address address = new Address() { City = "Moscow", Street = "Kalinina 20", PostalCode = "43433" }; context.Addresses.Add(address); IEnumerable <RoomType> roomTypes = new List <RoomType>() { new RoomType() { Name = "Single", Cost = 20M }, new RoomType() { Name = "Double", Cost = 40M }, new RoomType() { Name = "Studia", Cost = 70M }, new RoomType() { Name = "King", Cost = 200M }, }; foreach (var roomType in roomTypes) { context.RoomTypes.Add(roomType); } context.SaveChanges(); IEnumerable <Room> rooms = new List <Room>() { new Room() { Number = "1", RoomType = roomTypes.ElementAt(0), IsReserved = true }, new Room() { Number = "2", RoomType = roomTypes.ElementAt(0), IsReserved = false }, new Room() { Number = "3", RoomType = roomTypes.ElementAt(3), IsReserved = true }, new Room() { Number = "4", RoomType = roomTypes.ElementAt(1), IsReserved = false }, new Room() { Number = "5", RoomType = roomTypes.ElementAt(2), IsReserved = false } }; foreach (var room in rooms) { context.Rooms.Add(room); } context.SaveChanges(); Hotel hotel = new Hotel() { Address = address, Rooms = rooms }; context.Hotels.Add(hotel); context.SaveChanges(); IEnumerable <Guest> guests = new List <Guest>() { new Guest() { Name = "Petr", Surname = " Ivanov", PassportNumber = "ms32324234234" }, new Guest() { Name = "Lidia", Surname = "Pavlova", PassportNumber = "342423ee4wq234" }, new Guest() { Name = "Ivan", Surname = " Koren'", PassportNumber = "qs34asd33232" } }; foreach (var guest in guests) { context.Guests.Add(guest); } context.SaveChanges(); //IEnumerable<RoomReservation> reservations = new List<RoomReservation>() //{ // new RoomReservation(){ Guest = guests.ElementAt(2), Room = rooms.ElementAt(3), Days = 3, ReservationStatus = RoomReservationStatus.Reserved }, // new RoomReservation(){ Guest = guests.ElementAt(1), Room = rooms.ElementAt(1), Days = 2, ReservationStatus = RoomReservationStatus.Reserved } //}; //foreach (var reservation in reservations) // context.RoomReservations.Add(reservation); //context.SaveChanges(); }
public async Task OnGetAsync(int id) { Hotel = await _hs.GetHotelFromIdAsync(id); }
public void ThenHotelWithNameShouldBePresentInTheResponse(string name) { hotel = hotels.Find(htl => htl.Name.ToLower().Equals(name.ToLower())); hotel.Should().NotBeNull(string.Format("Hotel with name {0} not found in response", name)); }
public async Task <ActionResult <Hotel> > PostHotel(Hotel hotel) { await _hotel.Create(hotel); return(CreatedAtAction("GetHotel", new { id = hotel.Id }, hotel)); }
public async Task <ActionResult <Hotel> > GetHotel(int id) { Hotel hotel = await _hotel.GetHotel(id); return(hotel); }
public Promociones(DateTime pFechaIni, DateTime pFechaFin, int pDias, int pPasajeros, string pTitulo, string pComentario, double pPrecio, Hotel pTienePromociones, Tipos pForma) { fechaInicio = pFechaIni; fechaFin = pFechaFin; dias = pDias; pasajeros = pPasajeros; titulo = pTitulo; comentario = pComentario; precio = pPrecio; tienePromociones = pTienePromociones; forma = pForma; }
public async Task CreateAsync(Hotel hotel) { _context.Hotels.Add(hotel); await _context.SaveChangesAsync(); }
private UIElement[] GenerateContent(DictionaryKind dictionary, SimpleRecord record) { List <UIElement> inputs = new List <UIElement>(); TextBox textBox; ComboBox comboBox; Grid content; switch (dictionary) { case DictionaryKind.Hotel: textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Hotel.Name)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, Hotel.GenerateTitle(nameof(Hotel.Name))); inputs.Add(textBox); comboBox = new ComboBox { Margin = new Thickness(0, 10, 0, 0) }; comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Hotel.City)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(comboBox, Hotel.GenerateTitle(nameof(Hotel.City))); comboBox.ItemsSource = Hotel.Empty.Equals(record) ? Dictionaries.GetNameList(DictionaryKind.City) : new List <string> { ((Hotel)record).City }; inputs.Add(comboBox); var stackPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 20, 0, 0) }; stackPanel.Children.Add(new TextBlock { Text = Hotel.GenerateTitle(nameof(Hotel.Type)) + ":", Margin = new Thickness(0, 0, 10, 0) }); RatingBar ratingBar = new RatingBar { Max = 5 }; ratingBar.SetBinding(RatingBar.ValueProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Hotel.Type)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); stackPanel.Children.Add(ratingBar); inputs.Add(stackPanel); break; case DictionaryKind.Ticket: comboBox = new ComboBox(); comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Ticket.Name)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(comboBox, Ticket.GenerateTitle(nameof(Ticket.Name))); comboBox.ItemsSource = Ticket.Empty.Equals(record) ? Dictionaries.GetNameList(DictionaryKind.Transport) : new List <string> { ((Ticket)record).Name }; inputs.Add(comboBox); content = new Grid { Margin = new Thickness(0, 10, 0, 0) }; content.ColumnDefinitions.Add(new ColumnDefinition()); content.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); content.ColumnDefinitions.Add(new ColumnDefinition()); comboBox = new ComboBox(); comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Ticket.From)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(comboBox, Ticket.GenerateTitle(nameof(Ticket.From))); comboBox.ItemsSource = Ticket.Empty.Equals(record) ? Dictionaries.GetNameList(DictionaryKind.City) : new List <string> { ((Ticket)record).From }; comboBox.SetValue(Grid.ColumnProperty, 0); content.Children.Add(comboBox); TextBlock textBlock = new TextBlock { Width = 10 }; textBlock.SetValue(Grid.ColumnProperty, 1); content.Children.Add(textBlock); comboBox = new ComboBox(); comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Ticket.To)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(comboBox, Ticket.GenerateTitle(nameof(Ticket.To))); comboBox.ItemsSource = Ticket.Empty.Equals(record) ? Dictionaries.GetNameList(DictionaryKind.City) : new List <string> { ((Ticket)record).To }; comboBox.SetValue(Grid.ColumnProperty, 2); content.Children.Add(comboBox); inputs.Add(content); textBox = new TextBox { Margin = new Thickness(0, 10, 0, 0) }; textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Ticket.Cost)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, Ticket.GenerateTitle(nameof(Ticket.Cost))); inputs.Add(textBox); break; case DictionaryKind.Agency: textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.Name)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, Agency.GenerateTitle(nameof(Agency.Name))); inputs.Add(textBox); content = new Grid { Margin = new Thickness(0, 10, 0, 0) }; content.ColumnDefinitions.Add(new ColumnDefinition()); content.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.Registration)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, Agency.GenerateTitle(nameof(Agency.Registration))); textBox.SetValue(Grid.ColumnProperty, 0); content.Children.Add(textBox); DatePicker datePicker = new DatePicker { Margin = new Thickness(10, 0, 0, 0) }; datePicker.SetBinding(DatePicker.SelectedDateProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.Date)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(datePicker, Agency.GenerateTitle(nameof(Agency.Date))); datePicker.SetValue(Grid.ColumnProperty, 1); content.Children.Add(datePicker); inputs.Add(content); content = new Grid { Margin = new Thickness(0, 10, 0, 0) }; content.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); content.ColumnDefinitions.Add(new ColumnDefinition()); comboBox = new ComboBox { Margin = new Thickness(0, 0, 10, 0), MinWidth = 60 }; comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.City)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(comboBox, Agency.GenerateTitle(nameof(Agency.City))); comboBox.ItemsSource = Dictionaries.GetNameList(DictionaryKind.City); comboBox.SetValue(Grid.ColumnProperty, 0); content.Children.Add(comboBox); textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.Address)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, Agency.GenerateTitle(nameof(Agency.Address))); textBox.SetValue(Grid.ColumnProperty, 1); content.Children.Add(textBox); inputs.Add(content); comboBox = new ComboBox { Margin = new Thickness(0, 10, 0, 0) }; comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.Ownership)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(comboBox, Agency.GenerateTitle(nameof(Agency.Ownership))); comboBox.ItemsSource = Dictionaries.GetNameList(DictionaryKind.Ownership); inputs.Add(comboBox); textBox = new TextBox { Margin = new Thickness(0, 10, 0, 0), MaxLength = 12 }; textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(Agency.Phone)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, Agency.GenerateTitle(nameof(Agency.Phone))); inputs.Add(textBox); break; default: { textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(DictionaryRecordViewModel.Record) + '.' + nameof(DictionaryRecordViewModel.Record.Name)) { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); HintAssist.SetHint(textBox, SimpleRecord.GenerateTitle()); inputs.Add(textBox); break; } } return(inputs.ToArray()); }
public void ShouldCreateNewHotelWithProvidedId() { var hotel = new Hotel(1, new List <ReservationStepType>()); hotel.HotelId.Should().Be(1); }
public async Task <IActionResult> Post([FromBody] Hotel hotel) { var createHotel = await _hotelService.UpdateHotel(hotel); return(CreatedAtAction("Get", new { id = createHotel.Id }, createHotel)); }
public async Task CreateIndexerAsync() { await using SearchResources resources = await SearchResources.CreateWithBlobStorageAsync(this, populate : true); Environment.SetEnvironmentVariable("SEARCH_ENDPOINT", resources.Endpoint.ToString()); Environment.SetEnvironmentVariable("SEARCH_API_KEY", resources.PrimaryApiKey); Environment.SetEnvironmentVariable("STORAGE_CONNECTION_STRING", resources.StorageAccountConnectionString); Environment.SetEnvironmentVariable("STORAGE_CONTAINER", resources.BlobContainerName); Environment.SetEnvironmentVariable("COGNITIVE_SERVICES_KEY", resources.CognitiveServicesKey); // Define clean up tasks to be invoked in reverse order added. Stack <Func <Task> > cleanUpTasks = new Stack <Func <Task> >(); try { #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateSynonymMap // Create a new SearchIndexClient Uri endpoint = new Uri(Environment.GetEnvironmentVariable("SEARCH_ENDPOINT")); AzureKeyCredential credential = new AzureKeyCredential( Environment.GetEnvironmentVariable("SEARCH_API_KEY")); SearchIndexClient indexClient = new SearchIndexClient(endpoint, credential); /*@@*/ indexClient = resources.GetIndexClient(); // Create a synonym map from a file containing country names and abbreviations // using the Solr format with entry on a new line using \n, for example: // United States of America,US,USA\n string synonymMapName = "countries"; /*@@*/ synonymMapName = Recording.Random.GetName(); string synonymMapPath = "countries.txt"; /*@@*/ synonymMapPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Samples", "countries.txt"); SynonymMap synonyms; //@@using (StreamReader file = File.OpenText(synonymMapPath)) //@@{ //@@ synonyms = new SynonymMap(synonymMapName, file); //@@} /*@@*/ synonyms = new SynonymMap(synonymMapName, CountriesSolrSynonymMap); await indexClient.CreateSynonymMapAsync(synonyms); #endregion Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateSynonymMap // Make sure our synonym map gets deleted, which is not deleted when our // index is deleted when our SearchResources goes out of scope. cleanUpTasks.Push(() => indexClient.DeleteSynonymMapAsync(synonymMapName)); #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateIndex // Create the index string indexName = "hotels"; /*@@*/ indexName = Recording.Random.GetName(); SearchIndex index = new SearchIndex(indexName) { Fields = { new SimpleField("hotelId", SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true }, new SearchableField("hotelName") { IsFilterable = true, IsSortable = true }, new SearchableField("description") { AnalyzerName = LexicalAnalyzerName.EnLucene }, new SearchableField("descriptionFr") { AnalyzerName = LexicalAnalyzerName.FrLucene }, new SearchableField("tags", collection: true) { IsFilterable = true, IsFacetable = true }, new ComplexField("address") { Fields = { new SearchableField("streetAddress"), new SearchableField("city") { IsFilterable = true, IsSortable = true, IsFacetable = true }, new SearchableField("stateProvince") { IsFilterable = true, IsSortable = true, IsFacetable = true }, new SearchableField("country") { SynonymMapNames = new[] { synonymMapName },IsFilterable = true, IsSortable = true,IsFacetable = true }, new SearchableField("postalCode") { IsFilterable = true, IsSortable = true, IsFacetable = true } } } } }; await indexClient.CreateIndexAsync(index); #endregion Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateIndex // Make sure our synonym map gets deleted, which is not deleted when our // index is deleted when our SearchResources goes out of scope. cleanUpTasks.Push(() => indexClient.DeleteIndexAsync(indexName)); #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateDataSourceConnection // Create a new SearchIndexerClient SearchIndexerClient indexerClient = new SearchIndexerClient(endpoint, credential); /*@@*/ indexerClient = resources.GetIndexerClient(); string dataSourceConnectionName = "hotels"; /*@@*/ dataSourceConnectionName = Recording.Random.GetName(); SearchIndexerDataSourceConnection dataSourceConnection = new SearchIndexerDataSourceConnection( dataSourceConnectionName, SearchIndexerDataSourceType.AzureBlob, Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING"), new SearchIndexerDataContainer(Environment.GetEnvironmentVariable("STORAGE_CONTAINER"))); await indexerClient.CreateDataSourceConnectionAsync(dataSourceConnection); #endregion Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateDataSourceConnection // Make sure our data source gets deleted, which is not deleted when our // index is deleted when our SearchResources goes out of scope. cleanUpTasks.Push(() => indexerClient.DeleteDataSourceConnectionAsync(dataSourceConnectionName)); #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_Skillset // Translate English descriptions to French. // See https://docs.microsoft.com/azure/search/cognitive-search-skill-text-translation for details of the Text Translation skill. TextTranslationSkill translationSkill = new TextTranslationSkill( inputs: new[] { new InputFieldMappingEntry("text") { Source = "/document/description" } }, outputs: new[] { new OutputFieldMappingEntry("translatedText") { TargetName = "descriptionFrTranslated" } }, TextTranslationSkillLanguage.Fr) { Name = "descriptionFrTranslation", Context = "/document", DefaultFromLanguageCode = TextTranslationSkillLanguage.En }; // Use the human-translated French description if available; otherwise, use the translated description. // See https://docs.microsoft.com/azure/search/cognitive-search-skill-conditional for details of the Conditional skill. ConditionalSkill conditionalSkill = new ConditionalSkill( inputs: new[] { new InputFieldMappingEntry("condition") { Source = "= $(/document/descriptionFr) == null" }, new InputFieldMappingEntry("whenTrue") { Source = "/document/descriptionFrTranslated" }, new InputFieldMappingEntry("whenFalse") { Source = "/document/descriptionFr" } }, outputs: new[] { new OutputFieldMappingEntry("output") { TargetName = "descriptionFrFinal" } }) { Name = "descriptionFrConditional", Context = "/document", }; // Create a SearchIndexerSkillset that processes those skills in the order given below. string skillsetName = "translations"; /*@@*/ skillsetName = Recording.Random.GetName(); SearchIndexerSkillset skillset = new SearchIndexerSkillset( skillsetName, new SearchIndexerSkill[] { translationSkill, conditionalSkill }) { CognitiveServicesAccount = new CognitiveServicesAccountKey( Environment.GetEnvironmentVariable("COGNITIVE_SERVICES_KEY")) }; await indexerClient.CreateSkillsetAsync(skillset); #endregion Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_Skillset // Make sure our skillset gets deleted, which is not deleted when our // index is deleted when our SearchResources goes out of scope. cleanUpTasks.Push(() => indexerClient.DeleteSkillsetAsync(skillsetName)); #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateIndexer string indexerName = "hotels"; /*@@*/ indexerName = Recording.Random.GetName(); SearchIndexer indexer = new SearchIndexer( indexerName, dataSourceConnectionName, indexName) { // We only want to index fields defined in our index, excluding descriptionFr if defined. FieldMappings = { new FieldMapping("hotelId"), new FieldMapping("hotelName"), new FieldMapping("description"), new FieldMapping("tags"), new FieldMapping("address") }, OutputFieldMappings = { new FieldMapping("/document/descriptionFrFinal") { TargetFieldName = "descriptionFr" } }, Parameters = new IndexingParameters { // Tell the indexer to parse each blob as a separate JSON document. IndexingParametersConfiguration = new IndexingParametersConfiguration { ParsingMode = BlobIndexerParsingMode.Json } }, SkillsetName = skillsetName }; // Create the indexer which, upon successful creation, also runs the indexer. await indexerClient.CreateIndexerAsync(indexer); #endregion Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_CreateIndexer // Make sure our indexer gets deleted, which is not deleted when our // index is deleted when our SearchResources goes out of scope. cleanUpTasks.Push(() => indexerClient.DeleteIndexerAsync(indexerName)); // Wait till the indexer is done. await WaitForIndexingAsync(indexerClient, indexerName); #region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_Query // Get a SearchClient from the SearchIndexClient to share its pipeline. SearchClient searchClient = indexClient.GetSearchClient(indexName); /*@@*/ searchClient = InstrumentClient(new SearchClient(endpoint, indexName, credential, GetSearchClientOptions())); // Query for hotels with an ocean view. SearchResults <Hotel> results = await searchClient.SearchAsync <Hotel>("ocean view"); /*@@*/ bool found = false; await foreach (SearchResult <Hotel> result in results.GetResultsAsync()) { Hotel hotel = result.Document; /*@@*/ if (hotel.HotelId == "6") { Assert.IsNotNull(hotel.DescriptionFr); found = true; } Console.WriteLine($"{hotel.HotelName} ({hotel.HotelId})"); Console.WriteLine($" Description (English): {hotel.Description}"); Console.WriteLine($" Description (French): {hotel.DescriptionFr}"); } #endregion Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_Query Assert.IsTrue(found, "Expected hotel #6 not found in search results"); } finally { // We want to await these individual to create a deterministic order for playing back tests. foreach (Func <Task> cleanUpTask in cleanUpTasks) { await cleanUpTask(); } } }
public HotelRoomDummyCreator(Hotel hotel) { this.hotel = hotel; room = create(); }
public List <Hotel> PostHotel(Hotel h) { hotels.Add(h); return(hotels); }
initiateResponse IHiltonRoomService.Initiate(initiateRequest air_request) { initiateResponse lir_response; lir_response = new initiateResponse { HiltonRoomServiceProcessResponse = new HiltonRoomServiceProcessResponse() }; lir_response.HiltonRoomServiceProcessResponse.status = new Status(); try { DataSearchAvailableRoomsDTO ldsar_dsar; IHiltonRoomServiceBusiness lhrsb_hrsb; List <HotelDTO> llh_hotelesTemp; ldsar_dsar = new DataSearchAvailableRoomsDTO { City = air_request.HiltonRoomServiceProcessRequest.City, Country = air_request.HiltonRoomServiceProcessRequest.Country, CheckIn = air_request.HiltonRoomServiceProcessRequest.CheckIn, CheckOut = air_request.HiltonRoomServiceProcessRequest.CheckOut, Rooms = air_request.HiltonRoomServiceProcessRequest.Rooms, Type = air_request.HiltonRoomServiceProcessRequest.Type }; lhrsb_hrsb = new HiltonRoomServiceBusiness(); llh_hotelesTemp = lhrsb_hrsb.SearchAvailableRooms(ldsar_dsar); if (llh_hotelesTemp != null) { if (llh_hotelesTemp.Count > 0) { List <Hotel> llh_hoteles; llh_hoteles = new List <Hotel>(); foreach (HotelDTO lh_hotelTemp in llh_hotelesTemp) { Hotel lh_hotel; List <Room> llr_rooms; lh_hotel = new Hotel { Name = lh_hotelTemp.Name, Address = lh_hotelTemp.Address, City = lh_hotelTemp.City, Country = lh_hotelTemp.Country }; llr_rooms = new List <Room>(); foreach (RoomDTO lr_roomTemp in lh_hotelTemp.Rooms) { Room lr_room; lr_room = new Room { Number = lr_roomTemp.Number, Price = lr_roomTemp.Price, Type = lr_roomTemp.Type }; llr_rooms.Add(lr_room); } lh_hotel.Rooms = llr_rooms.ToArray(); llh_hoteles.Add(lh_hotel); } lir_response.HiltonRoomServiceProcessResponse.status.code = "00"; lir_response.HiltonRoomServiceProcessResponse.status.error = ""; lir_response.HiltonRoomServiceProcessResponse.result = llh_hoteles.ToArray(); } else { lir_response.HiltonRoomServiceProcessResponse.status.code = "01"; lir_response.HiltonRoomServiceProcessResponse.status.error = "No hay habitaciones disponibles con los parametros ingresados"; } } else { lir_response.HiltonRoomServiceProcessResponse.status.code = "01"; lir_response.HiltonRoomServiceProcessResponse.status.error = "Error en la ejecución del servicio"; } } catch (Exception ae_e) { Exception le_e; le_e = ae_e.InnerException != null ? ae_e.InnerException : ae_e; lir_response.HiltonRoomServiceProcessResponse.status.code = "01"; lir_response.HiltonRoomServiceProcessResponse.status.error = "Error en la ejecución del servicio:" + ae_e.Message; Common.CreateTrace.WriteLog(Common.CreateTrace.LogLevel.Error, "ERROR EN EL SERVICIO IHiltonRoomService Initiate:"); Common.CreateTrace.WriteLog(Common.CreateTrace.LogLevel.Error, " :: " + ae_e.Message); } return(lir_response); }
public async Task CreateHotelAsync(Hotel hotel) { await _context.AddAsync(hotel); await _context.SaveChangesAsync(); }
static List <Hotel> makeHotel() { var lstTipoPreco = new List <TipoPreco>(); var tPreco = new TipoPreco("REGULAR", "WEEK", 110); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REWARDS", "WEEK", 80); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REGULAR", "WEEKEND", 90); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REWARDS", "WEEKEND", 80); lstTipoPreco.Add(tPreco); var blackout = new Blockout(); blackout.Data = Convert.ToDateTime("01/02/2012"); var blackouts = new List <Blockout>(); blackouts.Add(blackout); var hotel = new Hotel("Lakewood", 3, lstTipoPreco); hotel.Blackouts = blackouts; var lstHotel = new List <Hotel>(); lstHotel.Add(hotel); //----------------------------------------------------- lstTipoPreco = new List <TipoPreco>(); tPreco = new TipoPreco("REGULAR", "WEEK", 160); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REWARDS", "WEEK", 110); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REGULAR", "WEEKEND", 60); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REWARDS", "WEEKEND", 50); lstTipoPreco.Add(tPreco); hotel = new Hotel("Bridgewood", 4, lstTipoPreco); lstHotel.Add(hotel); //------------------------------------------------------ lstTipoPreco = new List <TipoPreco>(); tPreco = new TipoPreco("REGULAR", "WEEK", 220); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REWARDS", "WEEK", 100); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REGULAR", "WEEKEND", 150); lstTipoPreco.Add(tPreco); tPreco = new TipoPreco("REWARDS", "WEEKEND", 40); lstTipoPreco.Add(tPreco); hotel = new Hotel("Lakewood", 5, lstTipoPreco); lstHotel.Add(hotel); return(lstHotel); }
public void OptionsHotel() { city = new City(); hotel = new Hotel(); string option = "S"; do { Console.Clear(); Console.WriteLine("Escriba 'C' para consultar todos los hoteles"); Console.WriteLine("Escriba 'CC' para consultar un hotel por ciudad"); Console.WriteLine("Escriba 'A' para añadir un hotel "); Console.WriteLine("Escriba 'M' para modificar un hotel "); Console.WriteLine("Escriba 'E' para eliminar un hotel "); Console.WriteLine("Escriba 'S' para volver al menú principal "); option = Console.ReadLine(); switch (option) { case "C": hotel.ConsultAll(); int optionConsult = 0; int idhotel = 0; do { Console.WriteLine("Escriba 0 para salir o 1 para consultar,insertar, actualizar y eliminar habitaciones por hotel"); string optionconsultaux = Console.ReadLine(); optionConsult = Int32.Parse(optionconsultaux); if (optionConsult == 0) { break; } else if (optionConsult == 1) { Console.WriteLine("Escriba el numero que identifica el hotel que desee, para consultar, añadir o eliminar habitaciones"); string idhotel4 = Console.ReadLine(); idhotel = Int32.Parse(idhotel4); hotel = new Hotel() { Id = idhotel }; hotel.OptionsRoom(); } else { Console.WriteLine("Opción no válida"); } }while (optionConsult != 0); Console.ReadKey(); break; case "c": hotel.ConsultAll(); int optionConsult1 = 0; int idhotel1 = 0; do { Console.WriteLine("Escriba 0 para salir o 1 para consultar,insertar, actualizar y eliminar habitaciones por hotel"); string optionconsultaux = Console.ReadLine(); optionConsult = Int32.Parse(optionconsultaux); if (optionConsult == 0) { break; } else if (optionConsult == 1) { Console.WriteLine("Escriba el numero que identifica el hotel que desee, para ver habitaciones"); string idhotel4 = Console.ReadLine(); idhotel = Int32.Parse(idhotel4); hotel = new Hotel() { Id = idhotel }; hotel.OptionsRoom(); } else { Console.WriteLine("Opción no válida"); } }while (optionConsult != 0); Console.ReadKey(); break; case "CC": Console.WriteLine("Escriba el identificador de la ciudad para consultar hoteles"); string idCityAux = Console.ReadLine(); int idCity = Int32.Parse(idCityAux); hotel = new Hotel() { IdCity = idCity }; hotel.ConsultByCity(); do { Console.WriteLine("Escriba 0 para salir o 1 para consultar,insertar, actualizar y eliminar habitaciones por hotel"); string optionconsultaux = Console.ReadLine(); optionConsult = Int32.Parse(optionconsultaux); if (optionConsult == 0) { break; } else if (optionConsult == 1) { Console.WriteLine("Escriba el numero que identifica el hotel que desee, para ver habitaciones"); string idhotel4 = Console.ReadLine(); idhotel = Int32.Parse(idhotel4); hotel = new Hotel() { Id = idhotel }; hotel.OptionsRoom(); } else { Console.WriteLine("Opción no válida"); } }while (optionConsult != 0); Console.ReadKey(); break; case "A": Console.WriteLine("Escriba el nombre del hotel"); string name = Console.ReadLine(); Console.WriteLine("Escriba la descripcion del hotel"); string description = Console.ReadLine(); Console.WriteLine("Escriba el nuevo teléfono del hotel"); string phone = Console.ReadLine(); Console.WriteLine("Escriba la dirección del hotel"); string address = Console.ReadLine(); Console.WriteLine("Escriba una url de la foto del hotel"); string photo = Console.ReadLine(); Picture photohotel = new Picture() { url = photo }; city.ConsultAll(); Console.WriteLine("Escriba el identificador de la ciudad a la que pertenece el hotel"); string idCityAux3 = Console.ReadLine(); int idCity1 = Int32.Parse(idCityAux3); hotel = new Hotel() { Name = name, Description = description, Phone = phone, Address = address, Photo = photohotel, IdCity = idCity1 }; hotel.Add(); Console.ReadKey(); break; case "a": Console.WriteLine("Escriba el nombre del hotel"); string name2 = Console.ReadLine(); Console.WriteLine("Escriba la descripcion del hotel"); string description2 = Console.ReadLine(); Console.WriteLine("Escriba el nuevo teléfono del hotel"); string phone2 = Console.ReadLine(); Console.WriteLine("Escriba la dirección del hotel"); string address2 = Console.ReadLine(); Console.WriteLine("Escriba una url de la foto del hotel"); string photo2 = Console.ReadLine(); Picture photohotel2 = new Picture() { url = photo2 }; city.ConsultAll(); Console.WriteLine("Escriba el identificador de la ciudad a la que pertenece el hotel"); string idCityAux2 = Console.ReadLine(); int idCity2 = Int32.Parse(idCityAux2); hotel = new Hotel() { Name = name2, Description = description2, Phone = phone2, Address = address2, Photo = photohotel2, IdCity = idCity2 }; hotel.Add(); Console.ReadKey(); break; case "M": hotel.ConsultAll(); Console.WriteLine("Escriba el Id del hotel a modificar"); string idaux = Console.ReadLine(); int id = Int32.Parse(idaux); Console.WriteLine("Escriba el nuevo nombre del hotel"); string name1 = Console.ReadLine(); Console.WriteLine("Escriba la nueva descripcion hotel"); string description1 = Console.ReadLine(); Console.WriteLine("Escriba el nuevo teléfono del hotel"); string phone1 = Console.ReadLine(); Console.WriteLine("Escriba la nueva dirección del hotel"); string address1 = Console.ReadLine(); Console.WriteLine("Escriba la nueva url de la foto del hotel"); string photoaux1 = Console.ReadLine(); Picture photo1 = new Picture() { url = photoaux1 }; city.ConsultAll(); Console.WriteLine("Escriba el identificador de la ciudad a la que pertenece el hotel"); string idCityAux1 = Console.ReadLine(); int idCity3 = Int32.Parse(idCityAux1); hotel = new Hotel() { Id = id, Name = name1, Description = description1, Phone = phone1, Address = address1, Photo = photo1, IdCity = idCity3 }; break; case "m": hotel.ConsultAll(); Console.WriteLine("Escriba el Id del hotel a modificar"); string idaux3 = Console.ReadLine(); int id3 = Int32.Parse(idaux3); Console.WriteLine("Escriba el nuevo nombre del hotel"); string name3 = Console.ReadLine(); Console.WriteLine("Escriba la nueva descripcion hotel"); string description3 = Console.ReadLine(); Console.WriteLine("Escriba el nuevo teléfono del hotel"); string phone3 = Console.ReadLine(); Console.WriteLine("Escriba la nueva dirección del hotel"); string address3 = Console.ReadLine(); Console.WriteLine("Escriba la nueva url de la foto del hotel"); string photoaux3 = Console.ReadLine(); Picture photo3 = new Picture() { url = photoaux3 }; city.ConsultAll(); Console.WriteLine("Escriba el identificador de la ciudad a la que pertenece el hotel"); string idCityAux4 = Console.ReadLine(); int idCity4 = Int32.Parse(idCityAux4); hotel = new Hotel() { Id = id3, Name = name3, Description = description3, Phone = phone3, Address = address3, Photo = photo3, IdCity = idCity4 }; break; case "E": hotel.ConsultAll(); Console.WriteLine("Escriba el Id del hotel a eliminar"); string idhotelaux = Console.ReadLine(); int idhotel2 = Int32.Parse(idhotelaux); hotel = new Hotel() { Id = idhotel2 }; hotel.Delete(); break; case "e": hotel.ConsultAll(); Console.WriteLine("Escriba el Id del hotel a eliminar"); string idhotelaux1 = Console.ReadLine(); int idhotel5 = Int32.Parse(idhotelaux1); hotel = new Hotel() { Id = idhotel5 }; hotel.Delete(); break; } }while (option != "S" && option != "s"); Console.ReadKey(); }
public ActionResult Details(int id) { Hotel hotel = GetHotels().FirstOrDefault(x => x.HotelId == id); return(View(hotel)); }
public void RoomActions(User user, Hotel hotel, Room room, Calendar calendar) { bool result; string menu, cardNumber; var dataService = new DataService(); Console.WriteLine("\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine($"\n\tПользователь: {user.Login}"); Console.WriteLine($"\tОтель: {hotel.Name}"); Console.WriteLine($"\tНомер: {room.Name}"); Console.WriteLine($"\tДаты заезда/выезда: {calendar.DateIn.ToShortDateString()} - {calendar.DateOut.ToShortDateString()}"); Console.WriteLine($"\tСтоимость: {calendar.Price} тнг"); if (calendar.Rezerv == 0 && calendar.Pay == 0) { while (true) { Console.WriteLine("\n\t1 - Забронировать номер"); Console.WriteLine("\t0 - Выход"); Console.Write("\n\tВаше выбор = "); menu = Console.ReadLine(); if (menu == "0") { break; } if (menu == "1") // забронировать отель { result = dataService.RezervUpdate(1, user, calendar); if (result) { Console.WriteLine("\n\tНомер забронирован."); Console.WriteLine("\t*******************"); } else { Console.WriteLine("\n\tНомер незабронирован."); Console.WriteLine("\t*********************"); } break; } continue; } } else if (calendar.Rezerv == 1 && calendar.Pay == 0 && calendar.UserId == user.Id) { while (true) { Console.WriteLine("\n\t1 - Оплатить"); Console.WriteLine("\t2 - Снять бронь с номера"); Console.WriteLine("\t0 - Выход\n"); Console.Write("\tВаш выбор = "); menu = Console.ReadLine(); if (menu == "0") { break; } if (menu == "1") // оплатить { Console.WriteLine("\n\tНомер Вашей банковской карточки, с которой будет произведена"); Console.Write($"\tоплата в размере {calendar.Price} тенге (0 - отказ) = "); cardNumber = Console.ReadLine(); if (cardNumber == "" || cardNumber == "0") { Console.WriteLine("\n\tНомер карты не введен, оплата не произведена."); Console.WriteLine("\t*********************************************"); } else { result = dataService.PayUpdate(user, calendar, cardNumber); if (result) { Console.WriteLine("\n\tОплата произведена."); Console.WriteLine("\t*******************"); } else { Console.WriteLine("\n\tОплата не произведена."); Console.WriteLine("\t**********************"); } }; break; } if (menu == "2") // снять бронь с номера { result = dataService.RezervUpdate(0, user, calendar); if (result) { Console.WriteLine("\n\tНомер снят с брони."); Console.WriteLine("\t*******************"); } else { Console.WriteLine("\n\tНомер не снят с брони."); Console.WriteLine("\t**********************"); } break; } continue; } } else if (calendar.Rezerv == 1 && calendar.Pay == 0 && calendar.UserId != user.Id) { Console.WriteLine("\n\tНомер забронирован другим пользователем."); Console.WriteLine("\t----------------------------------------"); } else if (calendar.Rezerv == 1 && calendar.Pay == 1) { Console.WriteLine("\n\tНомер уже забронирован и оплачен."); Console.WriteLine("\t---------------------------------"); } ; }
public bool Post([FromBody] Hotel value) { return(manageHotel.CreateHotel(value)); }
protected override void Seed(HotelReservationContext context) { //Let's initialize the database with some dummy data //Services first var accessible = new RoomService("Accessible"); var wifi = new RoomService("Wifi"); var sat = new RoomService("SatTV"); var safeLocker = new RoomService("SafeLocker"); var airConditioning = new RoomService("AirConditioning"); var bathtub = new RoomService("Bathtub"); //Some dates var today = DateTime.Today; var tomorrow = DateTime.Today.AddDays(1); var afterTomorrow = DateTime.Today.AddDays(2); var hotel1 = new Hotel("Flower Hotel") .WithRooms( new Room("Single room Violet", image: "violet") .HasRating(2.4m) .HasBasePrice(56.0m) .HasSpecialPrice(50.0m, from: tomorrow, nights: 3) .WithBeds(BedKind.Single, 1) .WithServices(wifi, airConditioning, accessible) .WithReservation("Michael Knight", today, nights: 1) .WithReservation("Bonnie Barstow", afterTomorrow, nights: 1), new Room("Single room Rose", image: "rose") .HasRating(3.2m) .HasBasePrice(62.0m) .HasSpecialPrice(60.0m, from: afterTomorrow, nights: 5) .WithBeds(BedKind.Single, 1) .WithServices(wifi, airConditioning, safeLocker, sat), new Room("Double room Sunflower", image: "sunflower") .HasRating(3.8m) .HasBasePrice(81.0m) .HasSpecialPrice(70.0m, from: today, nights: 3) .WithBeds(BedKind.Full, 1) .WithServices(wifi, safeLocker, bathtub, accessible) .WithReservation("John Annibal Smith", tomorrow, nights: 2), new Room("Double room Tulip", image: "tulip") .HasRating(3.8m) .HasBasePrice(82.0m) .HasSpecialPrice(60.0m, from: afterTomorrow, nights: 5) .WithBeds(BedKind.Single, 2) .WithServices(sat, bathtub) .WithReservation("Ally McBeal", today, nights: 1), new Room("Double room Daisy", image: "daisy") .HasRating(3.8m) .HasBasePrice(78.0m) .WithBeds(BedKind.King, 1) .WithServices(airConditioning, sat, accessible), new Room("Triple room Dandelion", image: "dandelion") .HasRating(3.3m) .HasBasePrice(92.0m) .HasSpecialPrice(90.0m, from: tomorrow, nights: 2) .WithBeds(BedKind.Single, 3) .WithServices(wifi, safeLocker, bathtub, airConditioning) .WithReservation("Thomas Magnum", afterTomorrow, nights: 1), new Room("Triple room Magnolia", image: "magnolia") .HasRating(4.0m) .HasBasePrice(127.0m) .HasSpecialPrice(100.0m, from: afterTomorrow, nights: 4) .WithBeds(BedKind.Single, 1) .WithBeds(BedKind.Full, 1) .WithServices(sat, accessible) .WithReservation("Fran Fine", afterTomorrow, nights: 2), new Room("Family room Daffodil", image: "daffodil") .HasRating(4.1m) .HasBasePrice(145.0m) .HasSpecialPrice(130.0m, from: today, nights: 3) .WithBeds(BedKind.Single, 2) .WithBeds(BedKind.King, 1) .WithServices(wifi, airConditioning, safeLocker, accessible) ); var hotel2 = new Hotel("Planet Hotel") .WithRooms( new Room("Single room Saturn", image: "saturn") .HasRating(3.1m) .HasBasePrice(62.0m) .HasSpecialPrice(56.0m, from: today, nights: 2) .WithBeds(BedKind.Single, 1) .WithServices(airConditioning, safeLocker) .WithReservation("Buffy Summers", today, nights: 1), new Room("Single room Mercury", image: "mercury") .HasRating(3.5m) .HasBasePrice(68.0m) .HasSpecialPrice(60.0m, from: today, nights: 5) .WithBeds(BedKind.Single, 1) .WithServices(wifi, sat, accessible) .WithReservation("Joey Potter", tomorrow, nights: 2), new Room("Double room Neptune", image: "neptune") .HasRating(3.9m) .HasBasePrice(86.0m) .HasSpecialPrice(76.0m, from: tomorrow, nights: 3) .WithBeds(BedKind.Full, 1) .WithServices(bathtub, airConditioning), new Room("Double room Mars", image: "mars") .HasRating(4.0m) .HasBasePrice(90.0m) .HasSpecialPrice(84.0m, from: afterTomorrow, nights: 3) .WithBeds(BedKind.Single, 2) .WithServices(wifi, bathtub, accessible) .WithReservation("Veronica Mars", afterTomorrow, nights: 1), new Room("Triple room Jupiter", image: "jupiter") .HasRating(4.5m) .HasBasePrice(112.0m) .HasSpecialPrice(100.0m, from: today, nights: 3) .WithBeds(BedKind.Single, 3) .WithServices(bathtub, airConditioning, accessible), new Room("Double room Venus", image: "venus") .HasRating(4.1m) .HasBasePrice(122.0m) .WithBeds(BedKind.Full, 1) .WithBeds(BedKind.Single, 2) .WithServices(wifi, safeLocker, airConditioning) .WithReservation("C.J. Parker", afterTomorrow, nights: 2) ); context.Hotels.Add(hotel1); context.Hotels.Add(hotel2); context.SaveChanges(); }
//Занесение данных из _services в контролы public void Build(Hotel hotel) { _hotel = hotel; _services = _hotel.Services; FillTable(); }
public bool Put(int id, [FromBody] Hotel value) { return(manageHotel.UpdateHotel(value, id)); }