Ejemplo n.º 1
0
        public static SongQueueResponseModel ToResponseModel(this SongQueueModel song)
        {
            if (song == null)
            {
                return(null);
            }

            return(new SongQueueResponseModel
            {
                User = song.User,
                RoomId = song.RoomId,
                SongId = song.SongId,
                Title = song.Title,
                Artist = song.Artist,
                AlbumName = song.AlbumName,
                AlbumImg = song.AlbumImg,
                Duration = song.Duration,
                Position = (DateTime.UtcNow - song.StartTime).TotalMilliseconds,
                EndTime = song.EndTime,
                ResquestTime = song.RequestTime,
                StartTime = song.StartTime
            });
        }
        public static IEnumerable <SongQueueModel> FixQueueSongGapTimings(this IEnumerable <SongQueueModel> songQueue, SongQueueModel gappedSong)
        {
            var gapSpan = TimeSpan.FromMilliseconds(gappedSong.Duration);

            return(songQueue.Select(x => new SongQueueModel()
            {
                AlbumImg = x.AlbumImg,
                AlbumName = x.AlbumName,
                Artist = x.Artist,
                Duration = x.Duration,
                EndTime = x.EndTime.Subtract(gapSpan),
                RequestTime = x.RequestTime,
                RoomId = x.RoomId,
                SongId = x.SongId,
                StartTime = x.StartTime.Subtract(gapSpan),
                Title = x.Title
            }));
        }