public IActionResult RenderVipList([FromBody] PlaylistItem[] data)
        {
            try
            {
                ViewBag.UserIsMod = User.Identity.IsAuthenticated;

                if (User.Identity.IsAuthenticated)
                {
                    var username = User.FindFirst(c => c.Type == TwitchAuthenticationConstants.Claims.DisplayName)
                                   ?.Value;
                    var twitchUser = new LoggedInTwitchUser
                    {
                        Username = username,
                        IsMod    = _modService.IsUserModerator(username)
                    };

                    ViewBag.UserIsMod = twitchUser?.IsMod ?? false;
                    ViewBag.Username  = twitchUser?.Username ?? string.Empty;
                }

                ViewBag.UserHasVip = User.Identity.IsAuthenticated && _vipApiClient.DoesUserHaveVip(
                    new DoesUserHaveVipRequestModel
                {
                    Username = User.Identity.Name.ToLower()
                }).Result.HasVip;

                ViewBag.IsPlaylistOpen = _playlistApiClient.IsPlaylistOpen().Result == PlaylistState.Open;
                return(PartialView("Partials/List/VipList", data));
            }
            catch (Exception)
            {
                return(Json(new { Success = false, Message = "Encountered an error" }));
            }
        }
        public async Task <IActionResult> List()
        {
            LoggedInTwitchUser twitchUser = null;

            ViewBag.UserIsMod = User.Identity.IsAuthenticated;

            if (User.Identity.IsAuthenticated)
            {
                var username = User.FindFirst(c => c.Type == TwitchAuthenticationConstants.Claims.DisplayName)
                               ?.Value;

                var userVips = await _vipApiClient.GetUserVipCount(new GetUserVipCountRequest
                {
                    Username = username
                });

                twitchUser = new LoggedInTwitchUser
                {
                    Username = username,
                    IsMod    = _modService.IsUserModerator(username),
                    Vips     = userVips?.Vips ?? 0
                };

                ViewBag.UserIsMod = twitchUser?.IsMod ?? false;
                ViewBag.Username  = twitchUser?.Username ?? string.Empty;
            }

            var allCurrentSongRequests = await _playlistApiClient.GetAllCurrentSongRequests();

            var playlistModel = new PlaylistViewModel
            {
                TwitchUser = twitchUser
            };

            if (allCurrentSongRequests != null)
            {
                playlistModel.CurrentSong = allCurrentSongRequests.CurrentSong;
                playlistModel.RegularList = allCurrentSongRequests.RegularList
                                            .Where(r => r.songRequestId != allCurrentSongRequests.CurrentSong.songRequestId).ToArray();
                playlistModel.VipList = allCurrentSongRequests.VipList
                                        .Where(r => r.songRequestId != allCurrentSongRequests.CurrentSong.songRequestId).ToArray();
            }

            ViewBag.UserHasVip = User.Identity.IsAuthenticated && (_vipApiClient.DoesUserHaveVip(
                                                                       new DoesUserHaveVipRequestModel
            {
                Username = User.Identity.Name.ToLower()
            })?.Result?.HasVip ?? false);

            var playlistTask = await _playlistApiClient.IsPlaylistOpen();

            ViewBag.IsPlaylistOpen = playlistTask == PlaylistState.Open;

            return(View(playlistModel));
        }
        private bool CheckAndSetUserModStatus()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(false);
            }

            if (User.Identity.IsAuthenticated)
            {
                var username = User?.FindFirst(c => c.Type == TwitchAuthenticationConstants.Claims.DisplayName)
                               ?.Value ?? string.Empty;
                var twitchUser = new LoggedInTwitchUser
                {
                    Username = username,
                    IsMod    = _modService.IsUserModerator(username)
                };

                ViewBag.UserIsMod = twitchUser?.IsMod ?? false;
            }

            return(ViewBag.UserIsMod);
        }
        public async Task <IActionResult> RenderCurrentSong([FromBody] PlaylistItem data)
        {
            try
            {
                ViewBag.UserIsMod = User.Identity.IsAuthenticated;

                if (User.Identity.IsAuthenticated)
                {
                    var username = User.FindFirst(c => c.Type == TwitchAuthenticationConstants.Claims.DisplayName)
                                   ?.Value;
                    var twitchUser = new LoggedInTwitchUser
                    {
                        Username = username,
                        IsMod    = _modService.IsUserModerator(username)
                    };
                    ViewBag.UserIsMod = twitchUser?.IsMod ?? false;

                    var apiResult = await _vipApiClient.DoesUserHaveVip(
                        new DoesUserHaveVipRequestModel
                    {
                        Username = User.Identity.Name.ToLower()
                    });

                    ViewBag.UserHasVip = apiResult.HasVip;
                }

                var playlistCheck = await _playlistApiClient.IsPlaylistOpen();

                ViewBag.IsPlaylistOpen = playlistCheck == PlaylistState.Open;
                return(PartialView("Partials/List/CurrentSong", data));
            }
            catch (Exception)
            {
                return(Json(new { Success = false, Message = "Encountered an error" }));
            }
        }