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