public void UniqueHash(BellumGensDbContext context)
 {
     if (string.IsNullOrEmpty(Hash))
     {
         Hash = Util.GenerateHashString(8);
         while (context.TournamentApplications.Where(t => t.Hash == Hash).SingleOrDefault() != null)
         {
             Hash = Util.GenerateHashString(8);
         }
     }
 }
예제 #2
0
 public void UniqueCustomUrl(BellumGensDbContext context)
 {
     if (string.IsNullOrEmpty(CustomUrl))
     {
         var    parts = TeamName.Split(' ');
         string url   = string.Join("-", parts);
         while (context.Teams.Where(t => t.CustomUrl == url).SingleOrDefault() != null)
         {
             if (url.Length > 58)
             {
                 url = url.Substring(0, 58);
             }
             url += '-' + Util.GenerateHashString(6);
         }
         CustomUrl = url;
     }
 }
예제 #3
0
        private void RefreshAppUserValues()
        {
            bool changes = false;

            if (steamUser?.avatarFull != user.AvatarFull)
            {
                user.AvatarFull = steamUser.avatarFull;
                changes         = true;
            }
            if (steamUser?.steamID != user.UserName)
            {
                user.UserName = steamUser.steamID;
                changes       = true;
            }
            if (steamUser?.avatarIcon != user.AvatarIcon)
            {
                user.AvatarIcon = steamUser.avatarIcon;
                changes         = true;
            }
            if (steamUser?.realname != user.RealName)
            {
                user.RealName = steamUser.realname;
                changes       = true;
            }
            if (steamUser?.avatarMedium != user.AvatarMedium)
            {
                user.AvatarMedium = steamUser.avatarMedium;
                changes           = true;
            }
            if (steamUser?.customURL != user.CustomUrl)
            {
                user.CustomUrl = steamUser.customURL;
                changes        = true;
            }
            if (steamUser?.country != user.Country)
            {
                user.Country = steamUser.country;
                changes      = true;
            }
            if (userStatsException != user.SteamPrivate)
            {
                user.SteamPrivate = userStatsException;
                changes           = true;
            }
            if (!userStatsException)
            {
                if (userStats?.headshotPercentage != user.HeadshotPercentage)
                {
                    user.HeadshotPercentage = userStats.headshotPercentage;
                    changes = true;
                }
                if (userStats?.killDeathRatio != user.KillDeathRatio)
                {
                    user.KillDeathRatio = userStats.killDeathRatio;
                    changes             = true;
                }
                if (userStats?.accuracy != user.Accuracy)
                {
                    user.Accuracy = userStats.accuracy;
                    changes       = true;
                }
            }
            if (changes)
            {
                using (BellumGensDbContext context = new BellumGensDbContext())
                {
                    try
                    {
                        ApplicationUser appuser = context.Users.Find(user.Id);
                        context.Entry(appuser).CurrentValues.SetValues(user);
                        context.SaveChanges();
                    }
                    catch
                    {
                    }
                }
            }
        }