private async void UserDialogControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.user != null && !this.user.IsAnonymous && !string.IsNullOrEmpty(this.user.Username))
            {
                await this.user.RefreshDetails(force : true);

                this.DataContext = this.user;

                this.PromoteToModButton.IsEnabled = this.DemoteFromModButton.IsEnabled = this.EditUserButton.IsEnabled = ChannelSession.IsStreamer;

                UserFollowModel follow = await ChannelSession.TwitchUserConnection.CheckIfFollowsNewAPI(this.user.GetTwitchNewAPIUserModel(), ChannelSession.TwitchUserNewAPI);

                if (follow != null && !string.IsNullOrEmpty(follow.followed_at))
                {
                    this.UnfollowButton.Visibility = System.Windows.Visibility.Visible;
                    this.FollowButton.Visibility   = System.Windows.Visibility.Collapsed;
                }

                if (this.user.UserRoles.Contains(UserRoleEnum.Banned))
                {
                    this.UnbanButton.Visibility = System.Windows.Visibility.Visible;
                    this.BanButton.Visibility   = System.Windows.Visibility.Collapsed;
                }

                if (this.user.UserRoles.Contains(UserRoleEnum.Mod))
                {
                    this.DemoteFromModButton.Visibility = System.Windows.Visibility.Visible;
                    this.PromoteToModButton.Visibility  = System.Windows.Visibility.Collapsed;
                }
            }
        }
        public IActionResult FollowOrUnfollow(long?id)
        {
            var user   = _context.Users.Single(x => x.UserName == User.Identity.Name);
            var artist = _context.Artists.Single(x => x.Id == id);

            var userFollow = new UserFollowModel();

            userFollow.User   = user;
            userFollow.Artist = artist;

            if (_context.UserFollows
                .Where(x => x.ArtistId == id && x.UserId == user.Id)
                .Count() == 0)
            {
                try
                {
                    _context.Add(userFollow);
                    _context.SaveChanges();
                }
                catch { }
            }
            else
            {
                _context.Remove(userFollow);
                _context.SaveChanges();
            }


            return(Redirect("/Artist/Details/" + id));
        }
Example #3
0
        public UserViewModel(UserFollowModel follow)
        {
            this.SetUserData(twitchID: follow.from_id);

            this.TwitchID          = follow.from_id;
            this.TwitchDisplayName = this.TwitchUsername = follow.from_name;

            this.SetTwitchRoles();
        }
        /// <summary>
        /// Creates a new instance of the FollowPacketModel class.
        /// </summary>
        /// <param name="serializedChatPacketArray">The serialized packet array</param>
        public FollowPacketModel(string serializedChatPacketArray)
            : base(serializedChatPacketArray)
        {
            JObject channel = (JObject)this.Payload.SelectToken("result.data.followers");

            if (channel != null)
            {
                this.Follow = channel.ToObject <UserFollowModel>();
            }
        }
Example #5
0
        private async Task RefreshTwitchUserFollowDate()
        {
            UserFollowModel follow = await ChannelSession.TwitchUserConnection.CheckIfFollowsNewAPI(ChannelSession.TwitchUserNewAPI, this.GetTwitchNewAPIUserModel());

            if (follow != null && !string.IsNullOrEmpty(follow.followed_at))
            {
                this.FollowDate = TwitchPlatformService.GetTwitchDateTime(follow.followed_at);
            }
            else
            {
                this.FollowDate = null;
            }
        }
Example #6
0
        public static async Task <UserViewModel> Create(UserFollowModel follow)
        {
            UserViewModel user = await UserViewModel.Create(StreamingPlatformTypeEnum.Twitch, follow.from_id);

            user.TwitchID          = follow.from_id;
            user.TwitchDisplayName = user.TwitchUsername = follow.from_name;

            user.SetTwitchRoles();

            ChannelSession.Settings.SetUserData(user.Data);

            return(user);
        }
Example #7
0
        public void FollowChannel()
        {
            TestWrapper(async(TwitchConnection connection) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection);

                ChannelModel channel = await connection.V5API.Channels.GetCurrentChannel();

                UserFollowModel result = await connection.V5API.Users.FollowChannel(user, channel);

                Assert.IsNotNull(result);
                Assert.IsNotNull(result.user);
                Assert.IsNotNull(result.user.id);
            });
        }
Example #8
0
        public void CheckUserFollow()
        {
            TestWrapper(async(TwitchConnection connection) =>
            {
                UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection);

                ChannelModel channel = await connection.V5API.Channels.GetCurrentChannel();

                Assert.IsNotNull(channel);
                Assert.IsNotNull(channel.id);

                UserFollowModel follow = await connection.V5API.Users.CheckUserFollow(user, channel);

                Assert.IsNotNull(follow);
            });
        }
Example #9
0
        public void GetFollowingUser()
        {
            TestWrapper(async(GlimeshConnection connection) =>
            {
                UserModel currentUser = await connection.Users.GetCurrentUser();
                Assert.IsNotNull(currentUser);
                Assert.IsTrue(!string.IsNullOrEmpty(currentUser.username));

                IEnumerable <UserFollowModel> follows = await connection.Users.GetFollowingUsers(currentUser);
                Assert.IsNotNull(follows);
                Assert.IsTrue(follows.Count() > 0);
                Assert.IsNotNull(follows.First());
                Assert.IsTrue(!string.IsNullOrEmpty(follows.First().id));

                UserFollowModel follow = await connection.Users.GetFollowingUser(currentUser, follows.First().user);
                Assert.IsNotNull(follow);
                Assert.IsTrue(!string.IsNullOrEmpty(follow.id));
            });
        }