public async Task <ActionResult> Delete(string id) { string userId = _httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString(); var timer = await _timerService.getByIdAsync(id); if (timer.userId != userId) { throw new UnauthorizedAccessException("Timer don't belong to you"); } await _timerService.deleteByIdAsync(timer.id); return(NoContent()); }