Пример #1
0
        public async Task <EsCreateJudgeCommandResponse> Handle
            (EsCreateJudgeCommand request, CancellationToken cancellationToken)
        {
            var validator       = new EsCreateJudgeCommandValidator();
            var validatorResult = await validator.ValidateAsync(request);

            if (!validatorResult.IsValid)
            {
                return(new EsCreateJudgeCommandResponse(validatorResult));
            }

            var judge = _mapper.Map <Judge>(request);

            var item = new JudgeAggregate(judge);

            _sessionForEventSourcing.Add <JudgeAggregate>(item);
            _sessionForEventSourcing.Commit();

            var ids = _mapper.Map <IdsDto>(judge.Ids());

            return(new EsCreateJudgeCommandResponse(ids));
        }
        public async Task <EsSubmitDeveloperCommandResponse> Handle
            (EsSubmitDeveloperCommand request, CancellationToken cancellationToken)
        {
            var validator       = new EsSubmitDeveloperCommandValidator();
            var validatorResult = await validator.ValidateAsync(request);

            if (!validatorResult.IsValid)
            {
                return(new EsSubmitDeveloperCommandResponse(validatorResult));
            }

            var developer = _mapper.Map <Developer>(request);

            var developerAgreggate = new DevloperAggregate(developer);

            _sessionForEventSourcing.Add <DevloperAggregate>(developerAgreggate);
            _sessionForEventSourcing.Commit();

            var ids = _mapper.Map <DeveloperIds>(developer.Ids());

            return(new EsSubmitDeveloperCommandResponse(ids));
        }
Пример #3
0
        public async Task <ESCreateCategoryCommandResponse> Handle
            (ESCreateCategoryCommand request, CancellationToken cancellationToken)
        {
            var validator       = new ESCreateCategoryCommandValidator();
            var validatorResult = await validator.ValidateAsync(request);

            if (!validatorResult.IsValid)
            {
                return(new ESCreateCategoryCommandResponse(validatorResult));
            }

            var category = _mapper.Map <Category>(request);

            var item = new CategoryAggregate(category);

            _sessionForEventSourcing.Add <CategoryAggregate>(item);
            _sessionForEventSourcing.Commit();

            var ids = _mapper.Map <IdsDto>(category.Ids());

            return(new ESCreateCategoryCommandResponse(ids));
        }
Пример #4
0
        public async Task <EsSubmitCallForSpeechCommandResponse> Handle
            (EsSubmitCallForSpeechCommand request, CancellationToken cancellationToken)
        {
            var validator       = new EsSubmitCallForSpeechCommandValidation();
            var validatorResult = await validator.ValidateAsync(request);

            if (!validatorResult.IsValid)
            {
                return(new EsSubmitCallForSpeechCommandResponse(validatorResult));
            }

            var csf = _mapper.Map <CallForSpeech>(request);

            var item = new CallForSpeechAggregate(csf);

            _sessionForEventSourcing.Add <CallForSpeechAggregate>(item);
            _sessionForEventSourcing.Commit();

            var ids = _mapper.Map <IdsDto>(csf.Ids());

            return(new EsSubmitCallForSpeechCommandResponse(ids));
        }