Esempio n. 1
0
        public async Task <Unit> Handle(CreateTopicCommand request, CancellationToken cancellationToken)
        {
            var topicId = Guid.NewGuid();

            await _topicRepository.CreateTopic(topicId, request);

            await _eventStore.SaveAsync <V1.TopicCreated>(new V1.TopicCreated[] { new V1.TopicCreated(topicId, request.Name) });

            return(Unit.Value);
        }
Esempio n. 2
0
        public ActionResult <TopicReadDto> CreateTopic(TopicCreateDto topicCreateDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var topicModel = _mapper.Map <Topic>(topicCreateDto);

            _repository.CreateTopic(topicModel);
            _repository.SaveChanges();
            var topicReadDto = _mapper.Map <TopicReadDto>(topicModel);

            //TODO: clean that up
            if (topicReadDto.user.Comments != null)
            {
                topicReadDto.user.Comments = null;
                topicReadDto.user.Topics   = null;
            }
            return(CreatedAtRoute(nameof(GetTopicById), new { Id = topicReadDto.Id }, topicReadDto));
        }
 public void CreateTopic(Topic topic)
 {
     _topicRepository.CreateTopic(topic);
 }