public IActionResult MoveVideo([FromBody] VideoMove data)
 {
     try
     {
         var userData  = jwtService.ParseData(this.User);
         var videoEdit = videoService.MoveVideo(data, userData.UserId);
         return(Ok(videoEdit));
     }
     catch (ServiceException e)
     {
         return(BadRequest(e.Message));
     }
 }
        public VideoMoveWithOrigin MoveVideo(VideoMove data, int userId)
        {
            var user = this.context.Users.SingleOrDefault(x => x.Id == userId);

            if (user == null)
            {
                throw new ServiceException("User Not Found!");
            }

            var video = this.context.Videos.SingleOrDefault(x => x.Id == data.videoId);

            if (video == null)
            {
                throw new ServiceException("Video Not Found!");
            }

            var origin = video.DirectoryId;

            if (video.DirectoryId == data.newDirectoryId)
            {
                return(null);
            }

            if (video.UserId != userId)
            {
                throw new ServiceException("Video Does Not Belong To You!");
            }

            var newDir = context.Directories.SingleOrDefault(x => x.Id == data.newDirectoryId);

            if (newDir == null)
            {
                throw new ServiceException("New Dir Not Found!");
            }

            if (newDir.UserId != userId)
            {
                throw new ServiceException("New Dir Does Not Belong To You!");
            }

            video.DirectoryId = data.newDirectoryId;
            context.SaveChanges();

            return(new VideoMoveWithOrigin
            {
                newDirectoryId = data.newDirectoryId,
                OriginDirectory = origin,
                videoId = data.videoId,
            });
        }