/// <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["CanNotDeleteItemReferencedInAikaQuest", referencedInQuests].Value); } List <KirjaPage> kirjaPages = await _kirjaPageDbAccess.GetPagesByItem(id); if (kirjaPages.Count > 0) { string mentionedInPages = string.Join(", ", kirjaPages.Select(p => p.Name)); return(_localizer["CanNotDeleteItemMentionedInKirjaPage", mentionedInPages].Value); } List <KartaMapMarkerQueryResult> kartaMaps = await _kartaMapDbAccess.GetAllMapsItemIsMarkedIn(id); if (kartaMaps.Count > 0) { string markedInMaps = string.Join(", ", kartaMaps.Select(m => m.Name)); return(_localizer["CanNotDeleteItemMarkedInKartaMap", 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 _kortistoNpcDbAccess.ResolveFlexFieldObjectNames(taleDialogs.Select(t => t.RelatedObjectId).ToList()); string referencedInDialogs = string.Join(", ", npcs.Select(n => n.Name)); return(_localizer["CanNotDeleteItemReferencedInTaleDialog", referencedInDialogs].Value); } List <KortistoNpc> inventoryNpcs = await _kortistoNpcDbAccess.GetNpcsByItemInInventory(id); if (inventoryNpcs.Count > 0) { string usedInInventories = string.Join(", ", inventoryNpcs.Select(n => n.Name)); return(_localizer["CanNotDeleteItemUsedInInventory", usedInInventories].Value); } List <KortistoNpc> referencedInDailyRoutines = await _kortistoNpcDbAccess.GetNpcsObjectIsReferencedInDailyRoutine(id); if (referencedInDailyRoutines.Count > 0) { string usedInDailyRoutines = string.Join(", ", referencedInDailyRoutines.Select(m => m.Name)); return(_localizer["CanNotDeleteItemUsedInDailyRoutine", usedInDailyRoutines].Value); } return(string.Empty); }
public async Task <IActionResult> GetPagesByItem(string itemId) { List <KirjaPage> pages = await _pageDbAccess.GetPagesByItem(itemId); return(Ok(pages)); }