Пример #1
0
        public Ability GetAbility(int ability_id) {
            Ability ability = null;
            using (IDbConnection connection = database.CreateOpenConnection()) {
                ability = VM_Ability.RetrieveSpecificAbility(connection, ability_id);
                if (ability == null) {
                    return ability;
                }
                ability.Generation = VM_Generation.RetrieveSpecificGeneration(connection, ability.Generation.Id);
                    
                if (ability.Generation != null && ability.Generation.MainRegion != null) {
                    ability.Generation.MainRegion = VM_Region.RetrieveSpecificRegion(connection, ability.Generation.MainRegion.Id);
                }

                ability.AbilityChangelog = VM_Ability.RetrieveSpecificAbilityChangelog(connection, ability.Id);
                foreach (AbilityChangelog ac in ability.AbilityChangelog) {
                    if (ac != null && ac.ChangedInVersionGroup != null) {
                        ac.ChangedInVersionGroup = VM_VersionGroups.RetrieveSpecificVersionGroups(connection, ac.ChangedInVersionGroup.Id);
                        ac.AbilityChangelogProse = VM_Ability.RetrieveSpecificAbilityChangelogProse(connection, ac.Id);
                        foreach (AbilityChangelogProse acp in ac.AbilityChangelogProse) {
                            acp.LocalLanguage = VM_Language.RetrieveSpecificLanguage(connection, acp.LocalLanguage.Id);
                        }

                        if (ac.ChangedInVersionGroup.Generation != null) {
                            ac.ChangedInVersionGroup.Generation = VM_Generation.RetrieveSpecificGeneration(connection, ac.ChangedInVersionGroup.Generation.Id);

                            if (ac.ChangedInVersionGroup.Generation.MainRegion != null) {
                                ac.ChangedInVersionGroup.Generation.MainRegion = VM_Region.RetrieveSpecificRegion(connection, ac.ChangedInVersionGroup.Generation.MainRegion.Id);
                            }
                        }
                    }
                }

                ability.AbilityName = VM_Ability.RetrieveSpecificAbilityName(connection, ability_id);
                foreach (AbilityName an in ability.AbilityName) {
                    if (an != null && an.LocalLanguage != null) {
                        an.LocalLanguage = VM_Language.RetrieveSpecificLanguage(connection, an.LocalLanguage.Id);
                    }
                }

                ability.AbilityProse = VM_Ability.RetrieveSpecificAbilityProse(connection, ability_id);
                foreach (AbilityProse ap in ability.AbilityProse) {
                    if (ap != null && ap.LocalLanguage != null) {
                        ap.LocalLanguage = VM_Language.RetrieveSpecificLanguage(connection, ap.LocalLanguage.Id);
                    }
                }
                connection.Close();
            } // Connection
            return ability;
        }