public async Task <Unit> Handle(UpdateVideoFragmentInterval request, CancellationToken cancellationToken)
        {
            var interval = request.Interval;
            var videoDb  =
                await VideoDb.GetByNameAndUserGuidAsync(DbContext, request.UserGuid, interval.FileName, cancellationToken);

            if (videoDb == null)
            {
                return(Unit.Value);
            }
            videoDb.UpdateProperty(DbContext, nameof(videoDb.StartTime), interval.StartTime);
            videoDb.UpdateProperty(DbContext, nameof(videoDb.EndTime), interval.EndTime);
            await DbContext.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
예제 #2
0
        public async Task <Unit> Handle(RemoveVideo request, CancellationToken cancellationToken)
        {
            var videoDb =
                await VideoDb.GetByNameAndUserGuidAsync(DbContext, request.UserGuid, request.FileName, cancellationToken);

            if (videoDb == null)
            {
                return(Unit.Value);
            }
            var watchedVideos = DbContext.WatchedVideos.Where(view => view.VideoId == view.Id);

            DbContext.WatchedVideos.RemoveRange(watchedVideos);
            DbContext.Videos.Remove(videoDb);
            await DbContext.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }