/// <summary> /// Compares a marker /// </summary> /// <param name="mapId">Id of the map</param> /// <param name="markerId">Id of the marker</param> /// <param name="markerType">Type of the marker</param> /// <param name="currentMarker">Current marker, if null the marker will be loaded</param> /// <returns>Compare Result</returns> public async Task <CompareResult> CompareMarker(string mapId, string markerId, MarkerType markerType, IImplementationComparable currentMarker = null) { KartaMap loadingMap = null; if (currentMarker == null) { loadingMap = await _mapDbAccess.GetMapById(mapId); } IImplementationComparable oldMarker = null; if (markerType == MarkerType.Npc) { oldMarker = await _markerSnapshotDbAccess.GetNpcMarkerSnapshotById(markerId); if (loadingMap != null && loadingMap.NpcMarker != null) { currentMarker = loadingMap.NpcMarker.First(m => m.Id == markerId); } } else if (markerType == MarkerType.Item) { oldMarker = await _markerSnapshotDbAccess.GetItemMarkerSnapshotById(markerId); if (loadingMap != null && loadingMap.ItemMarker != null) { currentMarker = loadingMap.ItemMarker.First(m => m.Id == markerId); } } else if (markerType == MarkerType.MapChange) { oldMarker = await _markerSnapshotDbAccess.GetMapChangeMarkerSnapshotById(markerId); if (loadingMap != null && loadingMap.MapChangeMarker != null) { currentMarker = loadingMap.MapChangeMarker.First(m => m.Id == markerId); } } else if (markerType == MarkerType.Quest) { oldMarker = await _markerSnapshotDbAccess.GetQuestMarkerSnapshotById(markerId); if (loadingMap != null && loadingMap.QuestMarker != null) { currentMarker = loadingMap.QuestMarker.First(m => m.Id == markerId); } } else if (markerType == MarkerType.Note) { oldMarker = await _markerSnapshotDbAccess.GetNoteMarkerSnapshotById(markerId); if (loadingMap != null && loadingMap.NoteMarker != null) { currentMarker = loadingMap.NoteMarker.First(m => m.Id == markerId); } } return(CompareObjects(currentMarker, oldMarker)); }
public async Task <IActionResult> FlagMarkerAsImplemented(string mapId, string markerId, MarkerType markerType) { // Check Data KartaMap map = await _mapDbAccess.GetMapById(mapId); if (map == null) { return(StatusCode((int)HttpStatusCode.NotFound)); } // Flag Marker as implemented if (markerType == MarkerType.Npc && map.NpcMarker != null) { NpcMapMarker marker = map.NpcMarker.First(m => m.Id == markerId); marker.IsImplemented = true; await _markerSnapshotDbAccess.SaveNpcMarkerSnapshot(marker); await _mapDbAccess.UpdateMap(map); } else if (markerType == MarkerType.Item && map.ItemMarker != null) { ItemMapMarker marker = map.ItemMarker.First(m => m.Id == markerId); marker.IsImplemented = true; await _markerSnapshotDbAccess.SaveItemMarkerSnapshot(marker); await _mapDbAccess.UpdateMap(map); } else if (markerType == MarkerType.MapChange && map.MapChangeMarker != null) { MapChangeMapMarker marker = map.MapChangeMarker.First(m => m.Id == markerId); marker.IsImplemented = true; await _markerSnapshotDbAccess.SaveMapChangeMarkerSnapshot(marker); await _mapDbAccess.UpdateMap(map); } else if (markerType == MarkerType.Quest && map.MapChangeMarker != null) { QuestMapMarker marker = map.QuestMarker.First(m => m.Id == markerId); marker.IsImplemented = true; await _markerSnapshotDbAccess.SaveQuestMarkerSnapshot(marker); await _mapDbAccess.UpdateMap(map); } else if (markerType == MarkerType.Note && map.NoteMarker != null) { NoteMapMarker marker = map.NoteMarker.First(m => m.Id == markerId); marker.IsImplemented = true; await _markerSnapshotDbAccess.SaveNoteMarkerSnapshot(marker); await _mapDbAccess.UpdateMap(map); } // Add Timeline entry await _timelineService.AddTimelineEntry(TimelineEvent.ImplementedMarker, mapId, markerId, markerType.ToString(), map.Name); return(Ok()); }
/// <summary> /// Syncs the npc name to markers after an update /// </summary> /// <param name="id">Id of the npc</param> /// <param name="npcName">New npc name</param> /// <returns>Task</returns> private async Task SyncNpcNameToMarkers(string id, string npcName) { List <KartaMapMarkerQueryResult> markerResult = await _kartaMapDbAccess.GetAllMapsNpcIsMarkedIn(id); foreach (KartaMapMarkerQueryResult curMapQueryResult in markerResult) { KartaMap map = await _kartaMapDbAccess.GetMapById(curMapQueryResult.MapId); foreach (NpcMapMarker curMarker in map.NpcMarker) { if (curMarker.NpcId == id) { curMarker.NpcName = npcName; } } await _kartaMapDbAccess.UpdateMap(map); } }
/// <summary> /// Syncs the page name to markers after an update /// </summary> /// <param name="id">Id of the page</param> /// <param name="pageName">New page name</param> /// <returns>Task</returns> private async Task SyncPageNameToMarkers(string id, string pageName) { List <KartaMapMarkerQueryResult> markerResult = await _kartaMapDbAccess.GetAllMapsKirjaPageIsMarkedIn(id); foreach (KartaMapMarkerQueryResult curMapQueryResult in markerResult) { KartaMap map = await _kartaMapDbAccess.GetMapById(curMapQueryResult.MapId); foreach (KirjaPageMapMarker curMarker in map.KirjaPageMarker) { if (curMarker.PageId == id) { curMarker.PageName = pageName; } } await _kartaMapDbAccess.UpdateMap(map); } }
/// <summary> /// Syncs the karta map change marker labels /// </summary> /// <param name="map">Map To sync</param> /// <returns>Task</returns> private async Task SyncKartaMapChangeMarkerLabels(KartaMap map) { if (map.MapChangeMarker == null) { return; } foreach (MapChangeMapMarker curMarker in map.MapChangeMarker) { KartaMap curMap = await _kartaMapDbAccess.GetMapById(curMarker.MapId); if (curMap == null) { continue; } curMarker.MapName = curMap.Name; } }
public async Task<IActionResult> Map(string id) { KartaMap map = await _mapDbAccess.GetMapById(id); if(!User.IsInRole(RoleNames.Kirja)) { map.KirjaPageMarker = new List<KirjaPageMapMarker>(); } if(!User.IsInRole(RoleNames.Kortisto)) { map.NpcMarker = new List<NpcMapMarker>(); } if(!User.IsInRole(RoleNames.Styr)) { map.ItemMarker = new List<ItemMapMarker>(); } if(!User.IsInRole(RoleNames.Aika)) { map.QuestMarker = new List<QuestMapMarker>(); } return Ok(map); }