// GET: /listener/delete/{id} public async Task <IActionResult> Delete(int id) { try { HttpListener listener = await _context.GetHttpListener(id); await _context.DeleteListener(listener.Id, _ListenerCancellationTokens); return(RedirectToAction(nameof(Index))); } catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException) { ModelState.AddModelError(string.Empty, e.Message); return(RedirectToAction(nameof(Index))); } }
public async Task <ActionResult> DeleteListener(int id) { try { await _context.DeleteListener(id, _ListenerCancellationTokens); return(new NoContentResult()); } catch (ControllerNotFoundException e) { return(NotFound(e.Message)); } catch (ControllerBadRequestException e) { return(BadRequest(e.Message)); } }