Ejemplo n.º 1
0
        private static User Create(IChatbotContext context, string username, bool deferSave)
        {
            var user = new User
            {
                Username                  = username,
                UsedVipRequests           = 0,
                UsedSuperVipRequests      = 0,
                SentGiftVipRequests       = 0,
                ModGivenVipRequests       = 0,
                FollowVipRequest          = 0,
                SubVipRequests            = 0,
                DonationOrBitsVipRequests = 0,
                ReceivedGiftVipRequests   = 0,
                TokenVipRequests          = 0,
                TokenBytes                = 0,
                TotalBitsDropped          = 0,
                TotalDonated              = 0,
                TimeLastInChat            = DateTime.UtcNow
            };

            context.Users.Add(user);

            if (!deferSave)
            {
                context.SaveChanges();
            }

            return(user);
        }
Ejemplo n.º 2
0
        private User AddUser(IChatbotContext context, string username, bool deferSave)
        {
            var userModel = new User
            {
                Username                  = username.ToLower(),
                UsedVipRequests           = 0,
                ModGivenVipRequests       = 0,
                FollowVipRequest          = 0,
                SubVipRequests            = 0,
                DonationOrBitsVipRequests = 0,
                TokenBytes                = 0,
                ReceivedGiftVipRequests   = 0,
                SentGiftVipRequests       = 0
            };

            try
            {
                context.Users.Add(userModel);
                if (!deferSave)
                {
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(userModel);
        }
Ejemplo n.º 3
0
        private void CloseExistingGames(IChatbotContext context)
        {
            // Unlikely, but ensure that other open games are closed

            var unclosedGames = context.SongGuessingRecords.Where(x => x.UsersCanGuess || x.IsInProgress);

            foreach (var unclosedGame in unclosedGames)
            {
                unclosedGame.UsersCanGuess = false;
                unclosedGame.IsInProgress  = false;
            }

            context.SaveChanges();
        }