add WIP code to save a room and create matching special offers

This commit is contained in:
Andreas Zweili 2018-08-28 21:51:46 +02:00
parent ad230ab0b9
commit c94aff0a6b
1 changed files with 25 additions and 2 deletions

View File

@ -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<string, List<Flight>> flights =
new Dictionary<string, List<Flight>>();
List<SpecialOffer> offers = new List<SpecialOffer>();
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();