public async Task <IActionResult> Delete(string id) { try { await _context.DeleteUser(id); 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> DeleteUser(string id) { try { await _context.DeleteUser(id); return(new NoContentResult()); } catch (ControllerNotFoundException e) { return(NotFound(e.Message)); } catch (ControllerBadRequestException e) { return(BadRequest(e.Message)); } catch (ControllerUnauthorizedException) { return(new UnauthorizedResult()); } }