示例#1
0
        public async Task <IdeaDTO> ExecuteAsync(IdeaRequest request)
        {
            var idea = await _ideasRepository.GetIdea(request.Id);

            if (idea == null)
            {
                throw new Exception("Idea not found");
            }

            var mappedIdea = _mapper.Map <IdeaDTO>(idea);

            return(mappedIdea);
        }
示例#2
0
        public async Task ExecuteAsync(AddIdeaCommand command)
        {
            if (await _usersRepository.GetUser(command.AuthorId) == null)
            {
                throw new Exception("User not found");
            }

            if (await _ideasReadRepository.GetIdea(command.Id) != null)
            {
                throw new Exception("Idea with same Id already exists");
            }

            var idea = _mapper.Map <Idea>(command);

            await _ideasWriteRepository.Save(idea);
        }