public void PerpareRegistrantDataForClient_With_Athlete_When_executed_return_dto(int sportId, int expected)

        {
            RegisteredAthlete athlete = new RegisteredAthlete {
                AthletesId = 219, Id = 67
            };
            Registrant registrant = new Registrant
            {
                FirstName   = "Clark",
                LastName    = "Kent",
                NickName    = "Superman",
                Id          = 1,
                ProgramId   = 10,
                SportId     = 4,
                Size        = "small",
                SportTypeId = 2,
                IsVolunteer = true,
                Selected    = true,
                TeamId      = 8,
            };

            registrant.RegisteredAthlete.Add(athlete);
            RegistrantDto actual = _worker.PrepareRegistrantDataForClient(registrant);

            Assert.Equal(athlete.Id, actual.RegisteredAthletesId);
            Assert.Equal(athlete.AthletesId, actual.AthletesId);
            //Assert.Equal(_athlete1.BirthDate, actual.BirthDate);
            Assert.Equal(_athlete1.MedicalExpirationDate, actual.MedicalExpirationDate);
            Assert.Equal(_athlete1.MF, actual.Gender);
        }
        public void PerpareRegistrantDataForClient_When_executed_return_dto(int sportId, int expected)

        {
            Registrant registrant = new Registrant
            {
                FirstName   = "Clark",
                LastName    = "Kent",
                NickName    = "Superman",
                Id          = 1,
                ProgramId   = 10,
                SportId     = 4,
                Size        = "small",
                SportTypeId = 2
            };
            RegistrantDto actual = _worker.PrepareRegistrantDataForClient(registrant);

            Assert.Equal(registrant.FirstName, actual.FirstName);
            Assert.Equal(registrant.LastName, actual.LastName);
            Assert.Equal(registrant.NickName, actual.NickName);
            Assert.Equal(registrant.Id, actual.Id);
            Assert.Equal(registrant.ProgramId, actual.ProgramId);
            Assert.Equal(registrant.SportId, actual.SportId);
            Assert.Equal(registrant.Size, actual.Size);
            Assert.Equal(registrant.SportTypeId, actual.SportTypeId);
        }
        public void PrepareRegistrantDataForClient_With_1_Email_When_executed_return_dto(int sportId, int expected)

        {
            RegisteredAthlete athlete = new RegisteredAthlete {
                AthletesId = 219, Id = 67
            };
            RegistrantEmail email1 = new RegistrantEmail()
            {
                Email = "*****@*****.**", Id = 15
            };
            Registrant registrant = new Registrant
            {
                FirstName   = "Clark",
                LastName    = "Kent",
                NickName    = "Superman",
                Id          = 1,
                ProgramId   = 10,
                SportId     = 4,
                Size        = "small",
                SportTypeId = 2,
                IsVolunteer = true,
                Selected    = true,
                TeamId      = 8,
            };

            registrant.RegisteredAthlete.Add(athlete);
            registrant.RegistrantEmail.Add(email1);
            RegistrantDto actual = _worker.PrepareRegistrantDataForClient(registrant);

            Assert.Equal(email1.Id, actual.RegistrantEmail1Id);
            Assert.Equal(email1.Email, actual.Email1);
        }
        public void PrepareRegistrantDataForClient_With_1_Phone_When_executed_return_dto(int sportId, int expected)

        {
            RegisteredAthlete athlete = new RegisteredAthlete {
                AthletesId = 219, Id = 67
            };
            RegistrantPhone phone1 = new RegistrantPhone {
                Phone = "703-555-1212", CanText = true, PhoneType = "cell", Id = 15
            };
            Registrant registrant = new Registrant
            {
                FirstName   = "Clark",
                LastName    = "Kent",
                NickName    = "Superman",
                Id          = 1,
                ProgramId   = 10,
                SportId     = 4,
                Size        = "small",
                SportTypeId = 2,
                IsVolunteer = true,
                Selected    = true,
                TeamId      = 8,
            };

            registrant.RegisteredAthlete.Add(athlete);
            registrant.RegistrantPhone.Add(phone1);
            RegistrantDto actual = _worker.PrepareRegistrantDataForClient(registrant);

            Assert.Equal(phone1.Id, actual.RegistrantPhone1Id);
            Assert.Equal(phone1.CanText, actual.CanText1);
            Assert.Equal(phone1.Phone, actual.Phone1);
            Assert.Equal(phone1.PhoneType, actual.PhoneType1);
        }
Beispiel #5
0
        private static void PreparePhones(Registrant registrant, RegistrantDto dto)
        {
            var phoneList = registrant.RegistrantPhone.ToList();

            foreach (var phone in phoneList)
            {
                if (dto.RegistrantPhone1Id == 0)
                {
                    dto.Phone1             = phone.Phone;
                    dto.CanText1           = phone.CanText;
                    dto.PhoneType1         = phone.PhoneType;
                    dto.RegistrantPhone1Id = phone.Id;
                }
                else
                {
                    if (dto.RegistrantPhone2Id == 0)
                    {
                        dto.Phone2             = phone.Phone;
                        dto.CanText2           = phone.CanText;
                        dto.PhoneType2         = phone.PhoneType;
                        dto.RegistrantPhone2Id = phone.Id;
                    }
                    else
                    {
                        dto.Phone3             = phone.Phone;
                        dto.CanText3           = phone.CanText;
                        dto.PhoneType3         = phone.PhoneType;
                        dto.RegistrantPhone3Id = phone.Id;
                    }
                }
            }
        }
Beispiel #6
0
        public RegistrantDto PrepareRegistrantDataForClient(Registrant registrant)
        {
            RegistrantDto dto = new RegistrantDto();

            dto.FirstName   = registrant.FirstName;
            dto.LastName    = registrant.LastName;
            dto.NickName    = registrant.NickName;
            dto.Id          = registrant.Id;
            dto.SportId     = registrant.SportId;
            dto.ProgramId   = registrant.ProgramId;
            dto.SportTypeId = registrant.SportTypeId;
            dto.Size        = registrant.Size;
            dto.IsVolunteer = registrant.IsVolunteer;
            dto.Selected    = registrant.Selected;
            dto.TeamId      = registrant.TeamId;
            var athlete = registrant.RegisteredAthlete.FirstOrDefault();

            if (athlete != null)
            {
                dto.RegisteredAthletesId = athlete.Id;
                dto.AthletesId           = athlete.AthletesId;
                var selectedAthlete = _athletes.FirstOrDefault(a => a.Id == athlete.AthletesId);
                if (selectedAthlete != null)
                {
                    dto.BirthDate             = selectedAthlete.BirthDate;
                    dto.MedicalExpirationDate = selectedAthlete.MedicalExpirationDate;
                    dto.Gender = selectedAthlete.MF;
                }
            }

            PreparePhones(registrant, dto);
            PrepareEmail(registrant, dto);

            return(dto);
        }
Beispiel #7
0
        private static void PrepareEmail(Registrant registrant, RegistrantDto dto)
        {
            var emailList = registrant.RegistrantEmail.ToList();

            foreach (var email in emailList)
            {
                if (dto.RegistrantEmail1Id == 0)
                {
                    dto.Email1             = email.Email;
                    dto.RegistrantEmail1Id = email.Id;
                }
                else
                {
                    if (dto.RegistrantEmail2Id == 0)
                    {
                        dto.Email2             = email.Email;
                        dto.RegistrantEmail2Id = email.Id;
                    }
                    else
                    {
                        dto.Email3             = email.Email;
                        dto.RegistrantEmail3Id = email.Id;
                    }
                }
            }
        }
        public async Task <int> Register(string fullname, string email, int[] favoriteIntegers, DateTime dateOfBirth, bool emailOptIn, DateTime timeOfRegistration)
        {
            var dto = new RegistrantDto
            {
                FullName             = fullname,
                Email                = email,
                EmailOptIn           = emailOptIn,
                DateOfBirth          = dateOfBirth,
                FavoriteIntegers     = favoriteIntegers,
                RegistrationDateTime = timeOfRegistration
            };

            return(await _registrationRepository.CreateRegistration(_mapper.Map <Registrant>(dto)));
        }
        public void PerpareRegistrantDataForClient_With_Optional_When_executed_return_dto(int sportId, int expected)

        {
            Registrant registrant = new Registrant
            {
                FirstName   = "Clark",
                LastName    = "Kent",
                NickName    = "Superman",
                Id          = 1,
                ProgramId   = 10,
                SportId     = 4,
                Size        = "small",
                SportTypeId = 2,
                IsVolunteer = true,
                Selected    = true,
                TeamId      = 8
            };
            RegistrantDto actual = _worker.PrepareRegistrantDataForClient(registrant);

            Assert.Equal(registrant.IsVolunteer, actual.IsVolunteer);
            Assert.Equal(registrant.Selected, actual.Selected);
            Assert.Equal(registrant.TeamId, actual.TeamId);
        }