public VideoRecordViewModel GetRecord(int videoId, int cid, int userid) { VideoLearnRecord videoRecord = _videoRecordDal.GetRecord(videoId, cid, userid); VideoRecordViewModel viewModels = iMapper.Map <VideoRecordViewModel>(videoRecord); return(viewModels); }
public async Task <bool> AddRecord(VideoLearnRecord videoLearnRecord, string imageIO) { if (!UploadHelper.UploadFile(videoLearnRecord.VideoImage, imageIO)) { return(false); } bool addState = true; VideoRecordViewModel viewModels = GetRecord(videoLearnRecord.VideoId, videoLearnRecord.Cid, videoLearnRecord.UserId); //查询当前用户观看记录信息 if (viewModels != null) //存在信息 { if (viewModels.WatchState == 2) //视频已观看完毕 { addState = await _videoRecordDal.AddRecord(videoLearnRecord) > 0; } else { //视频未看完 var videoImages = string.IsNullOrWhiteSpace(viewModels.VideoImage) ? videoLearnRecord.VideoImage : $"{ viewModels.VideoImage}|{videoLearnRecord.VideoImage}"; addState = await UpdateRecord(new VideoLearnRecord { Id = viewModels.Id, WatchLongTime = videoLearnRecord.WatchLongTime, WatchState = videoLearnRecord.WatchState, VideoImage = videoImages, FinishWatchTime = DateTime.Now }); } } else { addState = await _videoRecordDal.AddRecord(videoLearnRecord) > 0; } return(addState); }