public ActionResult <MarkerViewModel> CreateMarker([FromBody] MarkerDto markerDto)
        {
            if (ModelState.IsValid)
            {
                var markerViewModel = _markerRepo.Add(markerDto);

                return(Ok(markerViewModel));
            }
            else
            {
                return(BadRequest("ModelState is not valid"));
            }
        }
Beispiel #2
0
        public async Task <MarkerDto> CreateMarker(MarkerDto marker)
        {
            if (marker == null)
            {
                throw new InvalidOperationException();
            }

            var markerInDb = _mapper.Map <MarkerDto, Marker>(marker);

            markerInDb.IsActive = true;

            _markerRepository.Add(markerInDb);
            await _unitOfWork.CompleteAsync();

            return(_mapper.Map <Marker, MarkerDto>(markerInDb));
        }