From 49914d3cd8829f95a21ba0dc6ab478e7eeafd794 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Thu, 23 Aug 2018 22:48:13 +0200 Subject: [PATCH] add functionality to create a room --- Plattform/Plattform/Default.aspx.cs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Plattform/Plattform/Default.aspx.cs b/Plattform/Plattform/Default.aspx.cs index 15de1f1..d8edf21 100644 --- a/Plattform/Plattform/Default.aspx.cs +++ b/Plattform/Plattform/Default.aspx.cs @@ -12,8 +12,24 @@ namespace Plattform { public partial class Default: System.Web.UI.Page { + List Hotels { get; set; } + List RoomTypes { get; set; } protected void Page_Load(object sender, EventArgs e) { + HotelDB hotelDB = new HotelDB(); + RoomTypeDB roomTypeDB = new RoomTypeDB(); + + this.Hotels = hotelDB.GetAllHotels(); + DropDownHotel.DataSource = Hotels; + DropDownHotel.DataTextField = "Name"; + DropDownHotel.DataValueField = "HotelID"; + DropDownHotel.DataBind(); + + RoomTypes = roomTypeDB.GetAllRoomTypes(); + DropDownRoomType.DataSource = RoomTypes; + DropDownRoomType.DataTextField = "Name"; + DropDownRoomType.DataValueField = "RoomTypeID"; + DropDownRoomType.DataBind(); } protected void DropDownRoomType_SelectedIndexChanged(object sender, EventArgs e) @@ -37,7 +53,15 @@ namespace Plattform } protected void ButtonAddRoom_Click(object sender, EventArgs e) { - + RoomDB roomDB = new RoomDB(); + Room room = new Room + { + Hotel = this.Hotels.Single(h => h.HotelID == int.Parse(DropDownHotel.SelectedValue)), + RoomType = this.RoomTypes.Single(t => t.RoomTypeID == int.Parse(DropDownRoomType.SelectedValue)), + FreeFrom = CalendarFrom.SelectedDate, + FreeUntil = CalendarTo.SelectedDate + }; + roomDB.CreateRoom(room); } } -} \ No newline at end of file +}