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);
        }
Esempio n. 2
0
        public override async Task HandleAsync(TCommand command)
        {
            var contest = await Repository.Set <Contest>()
                          .SingleOrDefaultAsync(x => x.Id == command.ViewModel.ContestId);

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

            var validationResult = await ValidateCreateTeamContestRegistrationAsync(command.ViewModel);

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

            var registration = new TeamContestRegistration();

            _mapper.Map(command.ViewModel, registration);


            var registredForStudyPlaceCount = await Repository.Set <ContestRegistration>().CountAsync(r =>
                                                                                                      r.StudyPlaceId == registration.StudyPlaceId && r.ContestId == command.ViewModel.ContestId);

            string studyPlaceName = string.Empty;
            var    studyPlace     = await Repository.FindAsync <StudyPlace>(registration.StudyPlaceId);

            if (contest.ParticipantType == ParticipantType.Student && contest.IsEnglishLanguage && studyPlace is Institution inst)
            {
                studyPlaceName = inst.ShortNameEnglish;
            }
            else
            {
                studyPlaceName = studyPlace.ShortName;
            }

            string sharp = contest.ShowSharpTeamNumber ? "#" : "";

            registration.OfficialTeamName = $"{studyPlaceName} {sharp}{registredForStudyPlaceCount + 1}";

            await FinishRegistrationAsync(command.ViewModel, registration, contest);
        }
        private int AddTeamMember(ExcelWorksheet worksheet, ApplicationUser user, int row, TeamContestRegistration registration, string role)
        {
            worksheet.Cells[row, 1].Value = user.Email;
            worksheet.Cells[row, 2].Value = registration.DisplayTeamName;
            worksheet.Cells[row, 3].Value = user.FirstName;
            worksheet.Cells[row, 4].Value = user.LastName;
            worksheet.Cells[row, 5].Value = user.Surname;
            worksheet.Cells[row, 6].Value = user.Name;
            worksheet.Cells[row, 7].Value = user.Patronymic;
            worksheet.Cells[row, 8].Value = registration.StudyPlace.FullName;
            if (registration.StudyPlace is Institution institution)
            {
                worksheet.Cells[row, 9].Value  = institution.FullNameEnglish;
                worksheet.Cells[row, 10].Value = string.IsNullOrEmpty(institution.BaylorFullName) ? institution.FullNameEnglish : institution.BaylorFullName;
            }
            worksheet.Cells[row, 11].Value = registration.IsOutOfCompetition;
            worksheet.Cells[row, 12].Value = user.DateOfBirth.HasValue ? user.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty;
            worksheet.Cells[row, 13].Value = user.EducationStartDate.HasValue ? user.EducationStartDate.Value.ToString("dd.MM.yyyy") : string.Empty;
            worksheet.Cells[row, 14].Value = user.EducationEndDate.HasValue ? user.EducationEndDate.Value.ToString("dd.MM.yyyy") : string.Empty;
            worksheet.Cells[row, 15].Value = registration.StudyPlace.City.Name;
            worksheet.Cells[row, 16].Value = role;
            worksheet.Cells[row, 17].Value = user.PhoneNumber;
            worksheet.Cells[row, 18].Value = user.IsBaylorRegistrationCompleted;
            worksheet.Cells[row, 19].Value = user.StudentType ?? StudentType.Student;
            worksheet.Cells[row, 20].Value = registration.StudyPlace.City.Region?.Name;
            worksheet.Cells[row, 21].Value = registration.Status;

            return(row + 1);
        }