/// <summary>
        /// Resolves skill names
        /// </summary>
        /// <param name="skillIds">Skill Ids to resolve</param>
        /// <param name="differences">Differences to fill</param>
        private async Task ResolveSkillNames(List <string> skillIds, List <CompareDifference> differences)
        {
            skillIds = skillIds.Distinct().ToList();
            List <EvneSkill> skills = await _skillDbAccess.ResolveFlexFieldObjectNames(skillIds);

            Dictionary <string, string> skillLookup = skills.ToDictionary(i => i.Id, i => i.Name);

            FillObjectNames(differences, skillLookup, CompareDifferenceValue.ValueResolveType.ResolveSkillName, "SkillWasDeleted");
        }
Example #2
0
        public async Task <IActionResult> ValidateVersionReferences(string versionId)
        {
            KirjaPageVersion version = await _pageVersionDbAccess.GetPageVersionById(versionId);

            if (version == null)
            {
                return(NotFound());
            }

            PageVersionReferenceValidationResult validationResult = new PageVersionReferenceValidationResult();

            validationResult.MissingNpcs = new List <string>();
            if (version.MentionedNpcs != null)
            {
                List <KortistoNpc> npcs = await _npcDbAccess.ResolveFlexFieldObjectNames(version.MentionedNpcs);

                validationResult.MissingNpcs = version.MentionedNpcs.Where(n => !npcs.Any(npc => npc.Id.ToLowerInvariant() == n.ToLowerInvariant())).ToList();
            }

            validationResult.MissingItems = new List <string>();
            if (version.MentionedItems != null)
            {
                List <StyrItem> items = await _itemDbAccess.ResolveFlexFieldObjectNames(version.MentionedItems);

                validationResult.MissingItems = version.MentionedItems.Where(n => !items.Any(item => item.Id.ToLowerInvariant() == n.ToLowerInvariant())).ToList();
            }

            validationResult.MissingSkills = new List <string>();
            if (version.MentionedSkills != null)
            {
                List <EvneSkill> skills = await _skillDbAccess.ResolveFlexFieldObjectNames(version.MentionedSkills);

                validationResult.MissingSkills = version.MentionedSkills.Where(n => !skills.Any(skill => skill.Id.ToLowerInvariant() == n.ToLowerInvariant())).ToList();
            }

            validationResult.MissingQuests = new List <string>();
            if (version.MentionedQuests != null)
            {
                List <AikaQuest> quests = await _questDbAccess.ResolveQuestNames(version.MentionedQuests);

                validationResult.MissingQuests = version.MentionedQuests.Where(n => !quests.Any(quest => quest.Id.ToLowerInvariant() == n.ToLowerInvariant())).ToList();
            }

            validationResult.MissingPages = new List <string>();
            if (version.MentionedKirjaPages != null)
            {
                List <KirjaPage> pages = await _pageDbAccess.ResolveNames(version.MentionedKirjaPages);

                validationResult.MissingPages = version.MentionedKirjaPages.Where(n => !pages.Any(page => page.Id.ToLowerInvariant() == n.ToLowerInvariant())).ToList();
            }

            return(Ok(validationResult));
        }
Example #3
0
        /// <summary>
        /// Resolves the reference for object export snippets
        /// </summary>
        /// <param name="exportSnippets">Export snippets</param>
        /// <param name="includeNpcs">True if the npcs should be included</param>
        /// <param name="includeItems">True if the items should be included</param>
        /// <param name="includeSkills">True if the skills should be included</param>
        /// <returns>References</returns>
        public async Task <List <ObjectExportSnippetReference> > ResolveExportSnippetReferences(List <ObjectExportSnippet> exportSnippets, bool includeNpcs, bool includeItems, bool includeSkills)
        {
            Task <List <KortistoNpc> > npcsTask   = _npcDbAccess.ResolveFlexFieldObjectNames(exportSnippets.Select(o => o.ObjectId).ToList());
            Task <List <StyrItem> >    itemsTask  = _itemDbAccess.ResolveFlexFieldObjectNames(exportSnippets.Select(o => o.ObjectId).ToList());
            Task <List <EvneSkill> >   skillsTask = _skillDbAccess.ResolveFlexFieldObjectNames(exportSnippets.Select(o => o.ObjectId).ToList());

            await Task.WhenAll(npcsTask, itemsTask, skillsTask);

            Dictionary <string, string> npcs;

            if (includeNpcs)
            {
                npcs = npcsTask.Result.ToDictionary(n => n.Id, n => n.Name);
            }
            else
            {
                npcs = new Dictionary <string, string>();
            }

            Dictionary <string, string> items;

            if (includeItems)
            {
                items = itemsTask.Result.ToDictionary(i => i.Id, i => i.Name);
            }
            else
            {
                items = new Dictionary <string, string>();
            }

            Dictionary <string, string> skills;

            if (includeSkills)
            {
                skills = skillsTask.Result.ToDictionary(s => s.Id, s => s.Name);
            }
            else
            {
                skills = new Dictionary <string, string>();
            }

            List <ObjectExportSnippetReference> references = new List <ObjectExportSnippetReference>();

            foreach (ObjectExportSnippet snippet in exportSnippets)
            {
                string objectName = string.Empty;
                string objectType = string.Empty;
                if (npcs.ContainsKey(snippet.ObjectId))
                {
                    objectName = npcs[snippet.ObjectId];
                    objectType = ExportConstants.ExportObjectTypeNpc;
                }
                else if (items.ContainsKey(snippet.ObjectId))
                {
                    objectName = items[snippet.ObjectId];
                    objectType = ExportConstants.ExportObjectTypeItem;
                }
                else if (skills.ContainsKey(snippet.ObjectId))
                {
                    objectName = skills[snippet.ObjectId];
                    objectType = ExportConstants.ExportObjectTypeSkill;
                }
                else
                {
                    continue;
                }

                ObjectExportSnippetReference referenceResult = new ObjectExportSnippetReference();
                referenceResult.ObjectId      = snippet.ObjectId;
                referenceResult.ObjectName    = objectName;
                referenceResult.ObjectType    = objectType;
                referenceResult.ExportSnippet = snippet.SnippetName;
                references.Add(referenceResult);
            }

            return(references);
        }