diff --git a/Plattform/Plattform/Default.aspx.cs b/Plattform/Plattform/Default.aspx.cs index b4d70d0..840029f 100644 --- a/Plattform/Plattform/Default.aspx.cs +++ b/Plattform/Plattform/Default.aspx.cs @@ -6,7 +6,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using Plattform.Models; using Plattform.DB; -using Plattform; +using Plattform.AirlineService; namespace Plattform { @@ -57,10 +57,12 @@ namespace Plattform } protected void ButtonAddRoom_Click(object sender, EventArgs e) { + AirlineServiceClient client = new AirlineServiceClient(); LabelHotel.Text = ""; LabelRoomType.Text = ""; LabelAvailability.Text = ""; RoomDB roomDB = new RoomDB(); + SpecialOfferDB offerDB = new SpecialOfferDB(); if ((CalendarFrom.SelectedDate.Date == DateTime.MinValue.Date | CalendarTo.SelectedDate.Date == DateTime.MinValue.Date)) { @@ -84,7 +86,28 @@ namespace Plattform FreeFrom = CalendarFrom.SelectedDate, FreeUntil = CalendarTo.SelectedDate }; - roomDB.CreateRoom(room); + Dictionary> flights = + new Dictionary>(); + List offers = new List(); + flights = client.GetFlights(room.FreeFrom, room.FreeUntil, + room.Hotel.City.Name, + room.RoomType.Capacity); + foreach (var flight in flights["To"]) + { + SpecialOffer offer = new SpecialOffer(); + offer.FlightTo = flight; + offer.Room = room; + offer.Price = 100; + offers.Add(offer); + } + int counter = 0; + foreach (var offer in offers) + { + offer.FlightFrom = flights["From"][counter]; + offerDB.CreateSpecialOffer(offer); + counter += 1; + } + // roomDB.CreateRoom(room); DropDownHotel.ClearSelection(); DropDownRoomType.ClearSelection(); CalendarFrom.SelectedDates.Clear();