Beispiel #1
0
        public async Task <MapMarker> CreateMapMarkerAsync(
            NaheulbookExecutionContext executionContext,
            int mapLayerId,
            MapMarkerRequest request
            )
        {
            using var uow = _unitOfWorkFactory.CreateUnitOfWork();

            var mapLayer = await uow.MapLayers.GetAsync(mapLayerId);

            if (mapLayer == null)
            {
                throw new MapLayerNotFoundException(mapLayerId);
            }

            await _authorizationUtil.EnsureCanEditMapLayerAsync(executionContext, mapLayer);

            var mapMarker = new MapMarker
            {
                LayerId     = mapLayerId,
                Name        = request.Name,
                Description = request.Description,
                Type        = request.Type,
                MarkerInfo  = _jsonUtil.SerializeNonNull(request.MarkerInfo)
            };

            uow.MapMarkers.Add(mapMarker);

            await uow.SaveChangesAsync();

            return(mapMarker);
        }