Ejemplo n.º 1
0
        // 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));
                }
            }
        }