Exemplo n.º 1
0
        public static RankDetail GetRankForCallsign(CSSDataContext db, string callsign)
        {
            RankDetail rankDetail = new RankDetail();
            int?       loginID    = null;

            var alias = DataAccess.Alias.GetAliasByCallsign(db, callsign);

            // Get the oldest login from the alias for ranking.
            if (alias != null)
            {
                loginID = alias.Login.Identity.Logins.OrderBy(p => p.DateCreated).FirstOrDefault().Id;
            }

            if (loginID != null)
            {
                using (CSSStatsDataContext statsDB = new CSSStatsDataContext())
                {
                    var stats = statsDB.StatsLeaderboards.FirstOrDefault(p => p.LoginID == loginID.GetValueOrDefault(0));

                    if (stats != null)
                    {
                        double rank  = stats.Rank;
                        double sigma = stats.Sigma;
                        double mu    = stats.Mu;

                        // mask the user's rank if they are logging in as ACS and they are in a pilot role.
                        if (Char.IsLetter(callsign[0]) == true && callsign.EndsWith("@acs", StringComparison.InvariantCultureIgnoreCase) == true)
                        {
                            rank  = 8;
                            mu    = 32.85;
                            sigma = 6.54;
                        }

                        rankDetail.Rank         = rank;
                        rankDetail.Sigma        = sigma;
                        rankDetail.Mu           = mu;
                        rankDetail.CommandRank  = stats.CommandRank;
                        rankDetail.CommandSigma = stats.CommandSigma;
                        rankDetail.CommandMu    = stats.CommandMu;
                    }
                }
            }

            return(rankDetail);
        }
        public static RankDetail GetRankForCallsign(CSSDataContext db, string callsign)
        {
            RankDetail rankDetail = new RankDetail();
            int? loginID = null;

            var alias = DataAccess.Alias.GetAliasByCallsign(db, callsign);

            // Get the oldest login from the alias for ranking.
            if (alias != null)
                loginID = alias.Login.Identity.Logins.OrderBy(p => p.DateCreated).FirstOrDefault().Id;

            if (loginID != null)
            {
                using (CSSStatsDataContext statsDB = new CSSStatsDataContext())
                {
                    var stats = statsDB.StatsLeaderboards.FirstOrDefault(p => p.LoginID == loginID.GetValueOrDefault(0));

                    if (stats != null)
                    {
                        double rank = stats.Rank;
                        double sigma = stats.Sigma;
                        double mu = stats.Mu;

                        // mask the user's rank if they are logging in as ACS and they are in a pilot role.
                        if (Char.IsLetter(callsign[0]) == true && callsign.EndsWith("@acs", StringComparison.InvariantCultureIgnoreCase) == true)
                        {
                            rank = 8;
                            mu = 32.85;
                            sigma = 6.54;
                        }

                        rankDetail.Rank = rank;
                        rankDetail.Sigma = sigma;
                        rankDetail.Mu = mu;
                        rankDetail.CommandRank = stats.CommandRank;
                        rankDetail.CommandSigma = stats.CommandSigma;
                        rankDetail.CommandMu = stats.CommandMu;
                    }
                }
            }

            return rankDetail;
        }