public async Task <Unit> Handle(DeleteQuestionCommand request, CancellationToken cancellationToken)
        {
            _writeQuestionRepository.Delete(request.Id);

            await _writeQuestionRepository.SaveChangesAsync();

            return(Unit.Value);
        }
Example #2
0
        public async Task <Unit> Handle(CreateQuestionCommand request, CancellationToken cancellationToken)
        {
            var entity = _mapper.Map <Question>(request);

            entity.CreatedAt = DateTime.UtcNow;

            _writeQuestionRepository.Create(entity);

            await _writeQuestionRepository.SaveChangesAsync();

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateQuestionCommand request, CancellationToken cancellationToken)
        {
            if (request?.Id == null)
            {
                return(Unit.Value);                     //TODO: Add notification
            }
            var entity = _mapper.Map <Question>(request);

            _writeQuestionRepository.Update(entity);

            await _writeQuestionRepository.SaveChangesAsync();

            return(Unit.Value);
        }