//add unit private void AddUnit_OnClick(object sender, RoutedEventArgs e) { if (ChoosAccommodationToAddUnit.SelectedIndex == -1 || UnitNumber.Background != Brushes.White && UnitNumber.BorderBrush != Brushes.Gray || UnitPrice.Background != Brushes.White && UnitPrice.BorderBrush != Brushes.Gray) { MessageBox.Show("You must enter all the details", "Failed", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None); return; } HostingUnitWindow.HostId = HostId; HostingUnitWindow.UnitNumber = UnitNumber.Text; HostingUnitWindow.UnitPrice = Convert.ToDecimal(UnitPrice.Text); foreach (var item in AccommodationToBeUpdated) { if (item.AccommodationName == ChoosAccommodationToAddUnit.Text) { HostingUnitWindow.AccommodationKey = item.AccommodationKey; break; } } try { _instance.AddAHostingUnit(HostingUnitWindow); MessageBox.Show( "Your booking request has been received successfully, vacation offers will be sent to you soon ..."); var welcome = new Welcome(); welcome.Show(); Close(); } catch (Exception exception) { MessageBox.Show(exception.ToString(), "Failed", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None); } }
//add unit private void AddUnit_OnClick(object sender, RoutedEventArgs e) { if (ChoosAccommodationToAddUnit.SelectedIndex == -1 || UnitNumber.Background != Brushes.White && UnitNumber.BorderBrush != Brushes.Gray || UnitPrice.Background != Brushes.White && UnitPrice.BorderBrush != Brushes.Gray) { MessageBox.Show("You must enter all the details", "Failed", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None); return; } var hostingUnit = new HostingUnit(); hostingUnit.UnitOptions.Breakfast = (bool)ButtonBreakfast.Content; hostingUnit.UnitOptions.Lunch = (bool)ButtonLunch.Content; hostingUnit.UnitOptions.Dinner = (bool)ButtonDinner.Content; hostingUnit.UnitOptions.TwinBeds = (bool)ButtonTweenBed.Content; hostingUnit.UnitOptions.DoubleBed = (bool)ButtonDoubleBed.Content; hostingUnit.UnitOptions.BabyCrib = (bool)ButtonBadyCrib.Content; hostingUnit.UnitOptions.Bathtub = (bool)ButtonBathub.Content; hostingUnit.UnitOptions.PrivateBathroom = (bool)ButtonPrivetBathroom.Content; hostingUnit.UnitOptions.RoomService = (bool)ButtonRoomServis.Content; hostingUnit.UnitOptions.WashingMachine = (bool)ButtonLaundyservices.Content; hostingUnit.UnitOptions.Jacuzzi = (bool)UpdateButtonJacuzzi.Content; hostingUnit.UnitOptions.Pool = (bool)UpdateButtonPool.Content; hostingUnit.UnitOptions.Spa = (bool)UpdateButtonSpa.Content; hostingUnit.UnitOptions.Gym = (bool)UpdateButtonGym.Content; hostingUnit.UnitOptions.Terrace = (bool)UpdateButtonTerrece.Content; hostingUnit.UnitOptions.Garden = (bool)UpdateButtonGarden.Content; hostingUnit.UnitOptions.ChildrenAttractions = (bool)UpdateButtonChildrenAttraction.Content; hostingUnit.UnitOptions.AirConditioning = (bool)UpdateButtonAirConditioning.Content; hostingUnit.UnitOptions.WiFi = (bool)UpdateButtonWifi.Content; hostingUnit.UnitOptions.Tv = (bool)UpdateButtonTv.Content; hostingUnit.HostId = HostId; hostingUnit.UnitNumber = UnitNumber.Text; hostingUnit.UnitPrice = Convert.ToDecimal(UnitPrice.Text); foreach (var item in AccommodationToBeUpdated) { if (item.AccommodationName == ChoosAccommodationToAddUnit.Text) { hostingUnit.AccommodationKey = item.AccommodationKey; break; } } try { _instance.AddAHostingUnit(hostingUnit); MessageBox.Show( "Your booking request has been received successfully, vacation offers will be sent to you soon ..."); var welcome = new Welcome(); welcome.Show(); Close(); } catch (Exception exception) { MessageBox.Show(exception.ToString(), "Failed", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None); } }