private ContestRegistration CreateContestRegistrationForImportFromContest(ContestRegistration registration)
        {
            if (registration is TeamContestRegistration)
            {
                var source = (TeamContestRegistration)registration;
                var res    = new TeamContestRegistration
                {
                    Participant2Id   = source.Participant2Id,
                    Participant3Id   = source.Participant3Id,
                    TeamName         = source.TeamName,
                    OfficialTeamName = source.OfficialTeamName,
                };
                return(res);
            }

            var src    = (IndividualContestRegistration)registration;
            var indRes = new IndividualContestRegistration
            {
                Class       = src.Class,
                Course      = src.Course,
                StudentType = src.StudentType
            };

            return(indRes);
        }
Exemplo n.º 2
0
        public override async Task HandleAsync(TCommand command)
        {
            var contest = await Repository.FindAsync <Contest>(command.ViewModel.ContestId);

            if (contest == null)
            {
                throw new EntityNotFoundException();
            }

            var validationResult = await ValidateCreateIndividualContestRegistrationAsync(command.ViewModel);

            if (validationResult.Any())
            {
                throw new ValidationException(validationResult);
            }

            var registration = new IndividualContestRegistration();

            _mapper.Map(command.ViewModel, registration);

            await FinishRegistrationAsync(command.ViewModel, registration, contest);
        }