コード例 #1
0
        private void StoreUserReplays(string uid, ReplayFromLiveme videoInfo, ApplicationDBContext db)
        {
            var replay = db.Replays.Find(videoInfo.Vid);

            if (replay != null)
            {
                db.Remove(replay);
            }

            var user = db.StoreUser(uid, videoInfo.Uname);

            replay = new Replay
            {
                VId            = videoInfo.Vid,
                FromUser       = user,
                Title          = videoInfo.Title,
                CreatedAt      = replay?.CreatedAt ?? DateTime.UtcNow.ToUnixTimestamp(),
                VideoUrl       = videoInfo.Hlsvideosource.ToString(),
                StartTimeStamp = videoInfo.Vtime,
                ShareNum       = videoInfo.Sharenum,
                Watched        = replay?.Watched ?? false,
                Downloaded     = replay?.Downloaded ?? false,
                Duration       = TimeSpan.FromSeconds(videoInfo.Videolength),
                Liked          = replay?.Liked ?? false
            };

            db.Replays.Add(replay);
        }
コード例 #2
0
        public ReplayViewModel(ReplayFromLiveme r, List <Replay> replayCache)
        {
            var duration = TimeSpan.FromSeconds(r.Videolength);

            string PerMin(double num, int digits)
            {
                return((num / duration.TotalMinutes).ToString($"n{digits}"));
            }

            CheckAgainstCache(replayCache, r, out var watched, out var isnew, out var isLiked);
            SPM = PerMin(r.Sharenum, 1);
            LPM = PerMin(r.Likenum, 0);
            VPM = PerMin(r.Playnumber, 0);
            var tag = isnew ? "[NEW] " : "";

            Title    = tag + " " + r.Title;
            EyeStyle = watched ? "bright green" : "dim";
            Date     = r.Vtime.ToFormattedDateTime();
            Duration = TimeSpan.FromSeconds(r.Videolength).ToString();
            Likes    = r.Likenum.ToString();
            Views    = r.Playnumber.ToString();
            Shares   = r.Sharenum.ToString();
            Vid      = r.Vid;
            Watched  = watched;
            New      = isnew;
            IsLiked  = isLiked;
            // IconsHtml = isLiked ?  : "";
        }
コード例 #3
0
        private static void CheckAgainstCache(List <Replay> replayCache, ReplayFromLiveme r,
                                              out bool watched, out bool isNew, out bool isLiked)
        {
            var cache = replayCache.FirstOrDefault(c => c.VId == r.Vid);

            watched = cache?.Watched ?? false;
            isNew   = CheckIsNew(cache);
            isLiked = cache?.Liked ?? false;
        }