/// <summary> /// Set download file. /// </summary> /// <param name="releaseId">Release identifier.</param> /// <param name="videoId">Video identifier.</param> /// <param name="quality">Quality.</param> public void AddDownloadFile(long releaseId, OnlineVideoModel videoInfo, VideoQuality quality) { var releaseItem = m_Entity.DownloadingReleases.FirstOrDefault(a => a.ReleaseId == releaseId); if (releaseItem == null) { releaseItem = new DownloadReleaseEntity { ReleaseId = releaseId, Active = true, Videos = new List <DownloadReleaseVideoEntity> { new DownloadReleaseVideoEntity { IsDownloaded = false, Quality = quality, DownloadUrl = quality == VideoQuality.HD ? videoInfo.DownloadableHD.ToString() : videoInfo.DownloadableSD.ToString(), DownloadedSize = 0, Id = videoInfo.Order } } }; var list = m_Entity.DownloadingReleases.ToList(); list.Add(releaseItem); m_Entity.DownloadingReleases = list; } else { var video = releaseItem.Videos.Where(a => a.Id == videoInfo.Order && a.Quality == quality).FirstOrDefault(); if (video == null) { video = new DownloadReleaseVideoEntity { IsDownloaded = false, Quality = quality, DownloadUrl = quality == VideoQuality.HD ? videoInfo.DownloadableHD.ToString() : videoInfo.DownloadableSD.ToString(), DownloadedSize = 0, Id = videoInfo.Order }; var videos = releaseItem.Videos.ToList(); videos.Add(video); releaseItem.Videos = videos; releaseItem.Active = true; } } m_Collection.Update(m_Entity); }
private void ToggleSeenMark(OnlineVideoModel onlineVideo) { FillReleaseVideoState(); var videoState = m_ReleaseVideoStateEntity.VideoStates.FirstOrDefault(a => a.Id == onlineVideo.Order); if (videoState == null) { m_ReleaseVideoStateEntity.VideoStates.Add( new VideoStateEntity { Id = onlineVideo.Order, IsSeen = true } ); onlineVideo.IsSeen = true; } else { onlineVideo.IsSeen = !onlineVideo.IsSeen; videoState.IsSeen = onlineVideo.IsSeen; } m_ReleaseStateCollection.Update(m_ReleaseVideoStateEntity); }