private void CommitFormAction(object sender, EventArgs e) { Forms.ReservationForm form = sender as Forms.ReservationForm; switch (form.ClosedWith) { case Forms.CloseAction.Save: Models.Entities.MeetingReservation reservation = form.Reservation.Save(); if (!form.Reservation.Room.Reservations.ContainsKey(form.Reservation.Date.ToShortDateString()) || !form.Reservation.Room.Reservations[form.Reservation.Date.ToShortDateString()].Contains(reservation)) { form.Reservation.Room.AddReservation(reservation); } ViewModel.RefreshReservations(); break; case Forms.CloseAction.Delete: this.DeleteReservation(sender, null); ViewModel.RefreshReservations(); break; } }
private void EditReservation(object sender, RoutedEventArgs e) { Forms.ReservationForm form = new Forms.ReservationForm(ViewModel.SelectedReservation); form.Closed += CommitFormAction; form.ShowDialog(); }