Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            _logger.LogInformation(LoggingEvents.GetItem, "Get VehicleModel {ID}", id);

            VehicleModel = await _vehicleModelService.GetVehicleModelDelete(id);

            if (VehicleModel != null)
            {
                if (VehicleModel.HasReservation)
                {
                    return(RedirectToPage("./Index"));
                }
                else
                {
                    await _vehicleModelService.DeleteVehicle(id);

                    _logger.LogInformation(LoggingEvents.DeleteItem, "Admin deleted VehicleModel {ID}", id);
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            _logger.LogInformation(LoggingEvents.GetItem, "Get VehicleModel {ID}", id);
            VehicleModel = await _vehicleModelService.GetVehicleModelDelete(id);

            if (VehicleModel == null)
            {
                _logger.LogWarning(LoggingEvents.GetItemNotFound, "VehicleModel {ID} NOT FOUND", id);
                return(NotFound());
            }
            return(Page());
        }