コード例 #1
0
ファイル: KartaApiController.cs プロジェクト: TheN96/GoNorth
        public async Task<IActionResult> DeleteMap(string id) 
        {
            string error = await CheckMapReferencesForDeletion(id);
            if(!string.IsNullOrEmpty(error))
            {
                return BadRequest(error);
            }

            await DeleteAdditionalMapReferences(id);

            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(map.ProjectId, TimelineEvent.KartaMapDeleted, map.Name);
            return Ok(id);
        }
コード例 #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));
        }