Example #1
0
        public async Task <string> Handle(CreateStepCommand request, CancellationToken cancellationToken)
        {
            if (!await _languageRepository.LanguageExistById(request.LanguageId))
            {
                throw new ApplicationException($"Language {request.LanguageId} not found");
            }
            var step = StepEditionAggregate.CreateNew(
                await _stepEditionRepository.NextIdAsync(),
                request.Name,
                request.Description,
                request.HeaderCode,
                request.MinFunctionsCount,
                request.MaxFunctionsCount,
                request.Score,
                request.Difficulty,
                new ProgrammingLanguageId(request.LanguageId));
            var id = await _stepEditionRepository.SetAsync(step);

            return(id.ToString());
        }