Beispiel #1
0
        public async Task <ActionResult> DeleteVideo(string videoId, CancellationToken cancellationToken)
        {
            var userObjectId = this.CurrentUserProvider.GetObjectId();

            bool isVideoOwner = await VideoService.IsVideoOwnerAsync(videoId : videoId, azureAdB2cobjectId : userObjectId,
                                                                     cancellationToken : cancellationToken);

            if (!isVideoOwner)
            {
                throw new CustomValidationException($"Delete denied. You are not an owner of this video");
            }

            if (await VideoService.DeleteVideoAsync(userAzureAdB2cObjectId: userObjectId, videoId: videoId, cancellationToken))
            {
                return(Ok());
            }
            else
            {
                throw new CustomValidationException("An error occurred trying to delete your video");
            }
        }