public async Task <IActionResult> DeleteConfirmed(int id) { try { var spot = await _spotService.GetSingle(id); var isAuthorized = await _authorizationService.AuthorizeAsync(User, spot, Operation.Delete); if (!isAuthorized.Succeeded) { Forbid(); } await _spotService.Delete(id); await _spotService.Save(); return(RedirectToAction(nameof(Index))); } catch (BusinessException exception) { Console.WriteLine(exception); throw; } }
public async Task <IActionResult> DeleteSpot(int id) { var spot = _spotService.GetSingle(id); var isAuthorized = await _authorizationService.AuthorizeAsync(User, await spot, Operation.Delete); if (isAuthorized.Succeeded) { await _spotService.Delete(id); await _spotService.Save(); return(NoContent()); } return(StatusCode(403)); }