Esempio n. 1
0
        public Guild RetrieveGuild(string realm, string name)
        {
            Guild guild    = _blizzardConnectionRepository.GetGuild(name, realm, getMembers: true);
            Guild oldGuild = _guildRepository.GetGuild(realm, name);

            if (guild.Members != null && guild.Members.Count > 0)
            {
                List <Character> existingMembers = new List <Character>();
                if (oldGuild != null)
                {
                    existingMembers = _characterRepository.GetCharactersByGuild(oldGuild.Key.ToString()).ToList();
                }

                foreach (Character character in guild.Members)
                {
                    Character existingCharacter = existingMembers.Find(c => c.Realm == character.Realm && c.Name == character.Name) ?? _characterRepository.GetCharacter(character.Realm, character.Name);
                    if (existingCharacter != null)
                    {
                        character.Key = existingCharacter.Key;
                    }
                }
            }

            if (oldGuild == null)
            {
                _guildRepository.Add(guild);
            }
            else
            {
                guild.Key = oldGuild.Key;
                _guildRepository.Update(guild.Key.ToString(), guild);
            }

            return(_guildRepository.GetGuild(realm, name));
        }
Esempio n. 2
0
 public Guild Add(Guild guild)
 {
     return(_guildRepository.Add(guild));
 }