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); }
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); }