Ejemplo n.º 1
0
 /// <summary>
 ///     <see cref="ResourcesManager.Add(UCS.Logic.Clan)" /> the specified
 ///     clan to the in memory <see cref="UCS.Logic.Clan" /> s list.
 /// </summary>
 /// <param name="_Clan">The clan.</param>
 public static void Add(Clan _Clan)
 {
     if (Clans.ContainsKey(_Clan.ClanID))
     {
         Clans[_Clan.ClanID] = _Clan;
     }
     else
     {
         Clans.Add(_Clan.ClanID, _Clan);
     }
 }
Ejemplo n.º 2
0
        public IActionResult Clans()
        {
            logger.LogInformation("Clans");

            var data = new Clans();

            var badges = from c in db.Clans
                         select new ClanModel
            {
                Description      = c.Description,
                Image            = c.BadgeUrl,
                IsWarLogPublic   = c.IsWarLogPublic,
                Level            = c.ClanLevel,
                Location         = c.LocationName,
                Losses           = c.WarLosses,
                Name             = c.Name,
                Points           = c.ClanPoints,
                RequiredTrophies = c.RequiredTrophies,
                Tag          = c.Tag,
                Ties         = c.WarTies,
                Type         = c.Type,
                WarFrequency = c.WarFrequency,
                Wins         = c.WarWins,
                WinStreak    = c.WarWinStreak
            };

            var weights = new WeightCalculator(db).Calculate().ToDictionary(w => w.Tag);

            foreach (var row in badges)
            {
                if (weights.TryGetValue(row.Tag, out WeightCalculator.Results weight))
                {
                    row.Th14Count       = weight.Th14Count;
                    row.Th13Count       = weight.Th13Count;
                    row.Th12Count       = weight.Th12Count;
                    row.Th11Count       = weight.Th11Count;
                    row.Th10Count       = weight.Th10Count;
                    row.Th9Count        = weight.Th9Count;
                    row.Th8Count        = weight.Th8Count;
                    row.ThLowCount      = weight.ThLowCount;
                    row.EstimatedWeight = weight.EstimatedWeight;
                }

                data.Add(row);
            }

            return(Ok(data));
        }