public void ReservButtonOnClick(object sender, RoutedEventArgs args) { if (int.TryParse(Duration.Text, out var durationInt)) { var duration = TimeSpan.FromMinutes(durationInt); if (When.SelectedDate.HasValue) { if (AvailableTimes.SelectedItem != null && AvailableBoats.SelectedItem != null) { var selectedTime = ((TimeViewModel)AvailableTimes.SelectedItem).Time; var selectedType = (BoatType)AvailableBoats.SelectedItem; var msg = _reservationService.PlaceReservation(selectedType.Id, _windowManager.UserSession.UserId, When.SelectedDate.Value + selectedTime, duration); StatusMessageUpdate?.Invoke(this, new MessageArgs(msg.Reason, msg.IsValid ? Type.Green : Type.Red)); if (msg.IsValid) { var userSession = _windowManager.UserSession; _mailService.SendConfirmation(userSession.Email, userSession.FirstName, When.SelectedDate.Value, selectedTime, duration); UpdateDictionary(); SetReservationData(); } } } } }
//Report damage free public void OnDisableDamageClick(object sender, RoutedEventArgs args) { var selectedItemObject = DeviceDataGrid.SelectedItem; if (selectedItemObject == null) { StatusMessageUpdate?.Invoke(this, new MessageArgs("Geen boot geselecteerd", Type.Red)); return; } var selectedType = (BoatTypeViewModel)selectedItemObject; if (selectedItemObject != null) { var result = _boatService.ReportDamage(selectedType.Id, _windowManager.UserSession.UserId, DateTime.Now); if (result) { _boatService.UpdateBoatStatus(selectedType.Id, BoatState.InStock); StatusMessageUpdate?.Invoke(this, new MessageArgs($"Boot {selectedType.Id} vrij gegeven", Type.Green)); SetBoatData(_boatService); } else { StatusMessageUpdate?.Invoke(this, new MessageArgs("Schade niet afgemeld.", Type.Red)); } } }
private void OnCancelClick(object sender, RoutedEventArgs e) { foreach (var data in DeviceDataGrid.SelectedItems) { _reservationService.CancelReservation(((ReservationViewModel)data).Id); } StatusMessageUpdate?.Invoke(this, new MessageArgs("Reservering(en) verwijderd.", Type.Green)); SetReservationData(); }
private void OnCancelClick(object sender, RoutedEventArgs e) { var toRemoveModel = new List <ReservationViewModel>(); foreach (var data in DeviceDataGrid.SelectedItems) { var model = (ReservationViewModel)data; _mailService.SendCancelConfirmation(model.Email, model.FirstName, model.ReservationDate); _reservationService.CancelReservation(model.Id); toRemoveModel.Add(model); } StatusMessageUpdate?.Invoke(this, new MessageArgs("Reservering(en) verwijderd.", Type.Green)); toRemoveModel.ForEach(x => Items.Remove(x)); }
// Damage report button public void OnReportDamageClick(object sender, RoutedEventArgs args) { var selectedItemObject = DeviceDataGrid.SelectedItem; if (selectedItemObject == null) { StatusMessageUpdate?.Invoke(this, new MessageArgs("Geen boot geselecteerd", Type.Red)); return; } var selectedType = (BoatTypeViewModel)selectedItemObject; if (selectedItemObject != null) { var result = _boatService.ReportDamage(selectedType.Id, _windowManager.UserSession.UserId, DateTime.Now); if (result) { _boatService.UpdateBoatStatus(selectedType.Id, BoatState.InService); var listresult = _reservationService.AllocateBoatReservations(selectedType.Id); foreach (var reservation in listresult) { _mailService.SendCancelMail(reservation.ReservedBy.Email, reservation.ReservedBy.FirstName, reservation.Date); } StatusMessageUpdate?.Invoke(this, new MessageArgs($"Schade gemeld", Type.Green)); SetBoatData(_boatService); } else { StatusMessageUpdate?.Invoke(this, new MessageArgs("Schade niet gemeld", Type.Red)); } } }
/// <summary> /// Called when [status message changed]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="StatusChangedEventArgs"/> instance containing the event data.</param> private void OnStatusMessageChanged(object sender, StatusChangedEventArgs e) { StatusMessageUpdate?.Invoke(sender, e); }