예제 #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            _logger.LogInformation(LoggingEvents.GetItem, "Get Address {ID}", id);
            Address = await _addressService.GetAddress(id);

            if (Address == null)
            {
                _logger.LogInformation(LoggingEvents.GetItemNotFound, "Get Address {ID} NOT FOUND", Address.Id);
                return(NotFound());
            }

            if (!_addressService.AddressHasReservations(id))
            {
                try
                {
                    await _addressService.DeleteAddress(id);

                    _logger.LogInformation(LoggingEvents.DeleteItem, "Admin Deleted Address {ID}", id);
                }
                catch (DbUpdateException)
                {
                }
            }


            return(RedirectToPage("./Index"));
        }