예제 #1
0
        public async Task <AttractionDto> Handle(CreateAttractionCommand request, CancellationToken cancellationToken)
        {
            var validator        = new CreateAttractionCommandValidator(_categoryRepository, _cityRepository);
            var validationResult = await validator.ValidateAsync(request);

            if (validationResult.Errors.Count > 0)
            {
                throw new ValidationException(validationResult);
            }

            var attraction = _mapper.Map <Attraction>(request);

            attraction = await _attractionRepository.AddAsync(attraction);

            var attractionDto = _mapper.Map <AttractionDto>(attraction);

            return(attractionDto);
        }