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); }
public async Task <ActionResult <MapMarkerResponse> > PostCreateMapMarkerAsync( [FromServices] NaheulbookExecutionContext executionContext, [FromRoute] int mapLayerId, [FromBody] MapMarkerRequest request ) { var map = await _mapService.CreateMapMarkerAsync(executionContext, mapLayerId, request); return(_mapper.Map <MapMarkerResponse>(map)); }
public async Task <ActionResult <MapMarkerResponse> > PutMarkerAsync( [FromServices] NaheulbookExecutionContext naheulbookExecutionContext, [FromRoute] int mapMarkerId, [FromBody] MapMarkerRequest request ) { try { var marker = await _mapService.EditMapMarkerAsync(naheulbookExecutionContext, mapMarkerId, request); return(_mapper.Map <MapMarkerResponse>(marker)); } catch (MapMarkerNotFoundException ex) { throw new HttpErrorException(StatusCodes.Status404NotFound, ex); } }