add WIP code to save a room and create matching special offers
This commit is contained in:
parent
ad230ab0b9
commit
c94aff0a6b
|
@ -6,7 +6,7 @@ using System.Web.UI;
|
||||||
using System.Web.UI.WebControls;
|
using System.Web.UI.WebControls;
|
||||||
using Plattform.Models;
|
using Plattform.Models;
|
||||||
using Plattform.DB;
|
using Plattform.DB;
|
||||||
using Plattform;
|
using Plattform.AirlineService;
|
||||||
|
|
||||||
namespace Plattform
|
namespace Plattform
|
||||||
{
|
{
|
||||||
|
@ -57,10 +57,12 @@ namespace Plattform
|
||||||
}
|
}
|
||||||
protected void ButtonAddRoom_Click(object sender, EventArgs e)
|
protected void ButtonAddRoom_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
AirlineServiceClient client = new AirlineServiceClient();
|
||||||
LabelHotel.Text = "";
|
LabelHotel.Text = "";
|
||||||
LabelRoomType.Text = "";
|
LabelRoomType.Text = "";
|
||||||
LabelAvailability.Text = "";
|
LabelAvailability.Text = "";
|
||||||
RoomDB roomDB = new RoomDB();
|
RoomDB roomDB = new RoomDB();
|
||||||
|
SpecialOfferDB offerDB = new SpecialOfferDB();
|
||||||
if ((CalendarFrom.SelectedDate.Date == DateTime.MinValue.Date
|
if ((CalendarFrom.SelectedDate.Date == DateTime.MinValue.Date
|
||||||
| CalendarTo.SelectedDate.Date == DateTime.MinValue.Date))
|
| CalendarTo.SelectedDate.Date == DateTime.MinValue.Date))
|
||||||
{
|
{
|
||||||
|
@ -84,7 +86,28 @@ namespace Plattform
|
||||||
FreeFrom = CalendarFrom.SelectedDate,
|
FreeFrom = CalendarFrom.SelectedDate,
|
||||||
FreeUntil = CalendarTo.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();
|
DropDownHotel.ClearSelection();
|
||||||
DropDownRoomType.ClearSelection();
|
DropDownRoomType.ClearSelection();
|
||||||
CalendarFrom.SelectedDates.Clear();
|
CalendarFrom.SelectedDates.Clear();
|
||||||
|
|
Loading…
Reference in New Issue