public async Task <IActionResult> DeleteEndpointByIdAsync(Guid endpointId, CancellationToken ct) { var existingEndpoint = await _endpointService.GetEndpointByIdAsync(endpointId, ct); if ((existingEndpoint == null) || existingEndpoint.Owner.IdentityId != _userInfoService.UserId) { return(NoContent()); } /* We are the owner of this endpoint so go ahead and delete it. */ var endpointDeleted = await _endpointService.DeleteEndpointByIdAsync(endpointId, ct); /* Something went wrong while trying to delete this endpoint. */ if (!endpointDeleted) { return(StatusCode(500, new ApiError("Device failed to be deleted"))); } return(NoContent()); }