/// <summary>
        /// Checks if a object is referenced before a delete
        /// </summary>
        /// <param name="id">Id</param>
        /// <returns>Empty string if no references exists, error string if references exists</returns>
        protected override async Task <string> CheckObjectReferences(string id)
        {
            List <AikaQuest> aikaQuests = await _aikaQuestDbAccess.GetQuestsObjectIsReferenced(id);

            if (aikaQuests.Count > 0)
            {
                string referencedInQuests = string.Join(", ", aikaQuests.Select(p => p.Name));
                return(_localizer["CanNotDeleteNpcReferencedInAikaQuest", referencedInQuests].Value);
            }

            List <KirjaPage> kirjaPages = await _kirjaPageDbAccess.GetPagesByNpc(id);

            if (kirjaPages.Count > 0)
            {
                string mentionedInPages = string.Join(", ", kirjaPages.Select(p => p.Name));
                return(_localizer["CanNotDeleteNpcMentionedInKirjaPage", mentionedInPages].Value);
            }

            List <KartaMapMarkerQueryResult> kartaMaps = await _kartaMapDbAccess.GetAllMapsNpcIsMarkedIn(id);

            if (kartaMaps.Count > 0)
            {
                string markedInMaps = string.Join(", ", kartaMaps.Select(m => m.Name));
                return(_localizer["CanNotDeleteNpcMarkedInKartaMap", markedInMaps].Value);
            }

            List <TaleDialog> taleDialogs = await _taleDbAccess.GetDialogsObjectIsReferenced(id);

            taleDialogs = taleDialogs.Where(t => t.RelatedObjectId != id).ToList();
            if (taleDialogs.Count > 0)
            {
                List <KortistoNpc> npcs = await _objectDbAccess.ResolveFlexFieldObjectNames(taleDialogs.Select(t => t.RelatedObjectId).ToList());

                string referencedInDialogs = string.Join(", ", npcs.Select(n => n.Name));
                return(_localizer["CanNotDeleteNpcReferencedInTaleDialog", referencedInDialogs].Value);
            }

            List <KortistoNpc> referencedInDailyRoutines = await((IKortistoNpcDbAccess)_objectDbAccess).GetNpcsObjectIsReferencedInDailyRoutine(id);

            if (referencedInDailyRoutines.Count > 0)
            {
                string usedInDailyRoutines = string.Join(", ", referencedInDailyRoutines.Select(m => m.Name));
                return(_localizer["CanNotDeleteNpcUsedInDailyRoutine", usedInDailyRoutines].Value);
            }

            return(string.Empty);
        }
Esempio n. 2
0
        public async Task <IActionResult> GetMapsByNpcId(string npcId)
        {
            List <KartaMapMarkerQueryResult> maps = await _mapDbAccess.GetAllMapsNpcIsMarkedIn(npcId);

            return(Ok(maps));
        }