Esempio n. 1
0
 /// <summary>
 /// Syncs the map name to markers after an update
 /// </summary>
 /// <param name="id">Id of the map</param>
 /// <param name="mapName">New map name</param>
 /// <returns>Task</returns>
 private async Task SyncMapNameToMarkers(string id, string mapName)
 {
     List<KartaMap> markerResult = await _mapDbAccess.GetAllMapsMapIsMarkedIn(id);
     foreach(KartaMap curMap in markerResult)
     {
         KartaMap map = await _mapDbAccess.GetMapById(curMap.Id);
         foreach(MapChangeMapMarker curMarker in map.MapChangeMarker)
         {
             if(curMarker.MapId == id)
             {
                 curMarker.MapName = mapName;
             }
         }
         await _mapDbAccess.UpdateMap(map);
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> DeleteMap(string id)
        {
            List <KartaMap> kartaMaps = await _mapDbAccess.GetAllMapsMapIsMarkedIn(id);

            if (kartaMaps.Count > 0)
            {
                string markedInMaps = string.Join(", ", kartaMaps.Select(p => p.Name));
                return(StatusCode((int)HttpStatusCode.BadRequest, _localizer["CanNotDeleteMapMarkedInKartaMap", markedInMaps].Value));
            }

            KartaMap map = await _mapDbAccess.GetMapById(id);

            await _mapDbAccess.DeleteMap(map);

            _logger.LogInformation("Map was deleted.");

            _mapImageAccess.DeleteMapFolder(map.Id);
            _logger.LogInformation("Map image was deleted.");

            await _timelineService.AddTimelineEntry(TimelineEvent.KartaMapDeleted, map.Name);

            return(Ok(id));
        }