Ejemplo n.º 1
0
 private void Attributes(CincinnatiRegistration registration, int registrationId)
 {
     ChildAgeGroups(registration, registrationId);
     PrepWork(registration, registrationId);
     Equipment(registration, registrationId);
     ProjectPreferences(registration, registrationId);
 }
Ejemplo n.º 2
0
 private void ProjectPreferences(CincinnatiRegistration registration, int registrationId)
 {
     foreach (var projectPreference in registration.ProjectPreferences.Where(pref => pref.Id != 0))
     {
         _registrationService.AddProjectPreferences(registrationId, projectPreference.Id, projectPreference.Priority);
     }
 }
Ejemplo n.º 3
0
 private void PrepWork(CincinnatiRegistration registration, int registrationId)
 {
     foreach (var prepWork in registration.PrepWork)
     {
         _registrationService.AddPrepWork(registrationId, prepWork.Id, prepWork.Spouse);
     }
 }
Ejemplo n.º 4
0
        private List <HtmlElement> PrepWorkDetails(CincinnatiRegistration registration)
        {
            var prepWork = new List <HtmlElement>();

            if (registration.PrepWork.Count == 0)
            {
                prepWork.Add(BuildParagraph("Available for Prep Work: ", "No"));
                prepWork.Add(BuildParagraph("Spouse Available for Prep Work: ", "No"));
            }
            else if (registration.PrepWork.Count < 2 && registration.PrepWork[0].Spouse)
            {
                prepWork.Add(BuildParagraph("Available for Prep Work: ", "No"));
                prepWork.Add(BuildParagraph("Spouse Available for Prep Work: ", "Yes, from " + registration.PrepWork[0].Name));
            }
            else if (registration.PrepWork.Count < 2 && !registration.PrepWork[0].Spouse)
            {
                prepWork.Add(BuildParagraph("Available for Prep Work: ", "Yes, from " + registration.PrepWork[0].Name));
                prepWork.Add(BuildParagraph("Spouse Available for Prep Work: ", "No"));
            }
            else
            {
                prepWork.Add(BuildParagraph("Available for Prep Work: ", "Yes, from " + registration.PrepWork[0].Name));
                prepWork.Add(BuildParagraph("Spouse Available for Prep Work: ", "Yes, from " + registration.PrepWork[1].Name));
            }

            return(prepWork);
        }
Ejemplo n.º 5
0
        private MpContact SpouseInformation(CincinnatiRegistration registration)
        {
            if (!AddSpouse(registration))
            {
                return(new MpContact()
                {
                    ContactId = registration.Spouse.ContactId,
                    EmailAddress = registration.Spouse.EmailAddress ?? _contactService.GetContactEmail(registration.Spouse.ContactId)
                });
            }
            else
            {
                var contact = Observable.Start(() => _contactService.CreateSimpleContact(registration.Spouse.FirstName,
                                                                                         registration.Spouse.LastName,
                                                                                         registration.Spouse.EmailAddress,
                                                                                         registration.Spouse.DateOfBirth,
                                                                                         registration.Spouse.MobilePhone));
                contact.Subscribe <MpContact>(c =>
                {
                    Observable.CombineLatest(
                        Observable.Start(() => { _participantService.CreateParticipantRecord(c.ContactId); }),
                        Observable.Start(() => CreateRelationship(registration, c.ContactId))
                        );
                });

                return(contact.Wait());
            }
        }
Ejemplo n.º 6
0
 private void ChildAgeGroups(CincinnatiRegistration registration, int registrationId)
 {
     foreach (var ageGroup in registration.ChildAgeGroup)
     {
         _registrationService.AddAgeGroup(registrationId, ageGroup.Id, ageGroup.Count);
     }
 }
Ejemplo n.º 7
0
 private void Equipment(CincinnatiRegistration registration, int registrationId)
 {
     foreach (var equipment in registration.Equipment.Where(e => e != null))
     {
         var id = equipment.Id != 0 ? equipment.Id : _otherEquipmentId;
         _registrationService.AddEquipment(registrationId, id, equipment.Notes);
     }
 }
Ejemplo n.º 8
0
 private string Skills(CincinnatiRegistration registration)
 {
     if (registration.Skills != null && registration.Skills.Where(sk => sk.Checked).ToList().Count > 0)
     {
         return(registration.Skills.Where(sk => sk.Checked).Select(sk => sk.Name).Aggregate((first, next) => first + ", " + next));
     }
     return("");
 }
Ejemplo n.º 9
0
 private static bool AddSpouse(CincinnatiRegistration registration)
 {
     if (!registration.SpouseParticipation)
     {
         return(false);
     }
     return(registration.Spouse.ContactId == 0);
 }
Ejemplo n.º 10
0
        public Dictionary <string, object> SetupMergeData(CincinnatiRegistration registration)
        {
            var styles = Styles();

            var listOfP = ProfileDetails(registration);

            if (registration.SpouseParticipation)
            {
                listOfP = listOfP.Concat(SpouseDetails(registration)).ToList();
            }
            listOfP = listOfP.Concat(ChildrenDetails(registration)).ToList();
            if (registration.GroupConnector != null)
            {
                listOfP = listOfP.Concat(GroupConnectorDetails(registration)).ToList();
            }
            else
            {
                listOfP.Add(BuildParagraph("Preferred Launch Site: ", registration.PreferredLaunchSite.Name));
                listOfP.Add(BuildParagraph("Project Preference 1: ", registration.ProjectPreferences[0].Name));
                listOfP.Add(BuildParagraph("Project Preference 2: ", registration.ProjectPreferences[1].Name));
                listOfP.Add(BuildParagraph("Project Preference 3: ", registration.ProjectPreferences[2].Name));
            }
            if (registration.Skills != null && registration.Skills.Where(sk => sk.Checked).ToList().Count > 0)
            {
                listOfP.Add(BuildParagraph("Unique Skills: ", registration.Skills.Where(sk => sk.Checked).Select(sk => sk.Name).Aggregate((first, next) => first + ", " + next)));
            }

            if (registration.Equipment.Count > 0)
            {
                listOfP.Add(BuildParagraph("Special Equipment: ", registration.Equipment.Select(equip => equip.Notes).Aggregate((first, next) => first + ", " + next)));
            }
            if (registration.AdditionalInformation != null)
            {
                listOfP.Add(BuildParagraph("Additional Info: ", registration.AdditionalInformation));
            }
            listOfP = listOfP.Concat(PrepWorkDetails(registration)).ToList();

            var htmlCell  = new HtmlElement("td", styles).Append(listOfP);
            var htmlRow   = new HtmlElement("tr", styles).Append(htmlCell);
            var htmlTBody = new HtmlElement("tbody", styles).Append(htmlRow);
            var htmlTable = new HtmlElement("table", styles).Append(htmlTBody);


            var dict = new Dictionary <string, object>()
            {
                { "HTML_TABLE", htmlTable.Build() },
                { "Nickname", registration.Self.FirstName },
                { "Lastname", registration.Self.LastName },
            };

            if (registration.SpouseParticipation)
            {
                dict.Add("Spouse_Nickname", registration.Spouse.FirstName);
                dict.Add("Spouse_Lastname", registration.Spouse.LastName);
            }

            return(dict);
        }
Ejemplo n.º 11
0
 private void GroupConnector(CincinnatiRegistration registration, int registrationId)
 {
     if (registration.CreateGroupConnector)
     {
         _groupConnectorService.CreateGroupConnector(registrationId, registration.PrivateGroup);
     }
     else if (registration.GroupConnector.GroupConnectorId != 0)
     {
         _groupConnectorService.CreateGroupConnectorRegistration(registration.GroupConnector.GroupConnectorId, registrationId);
     }
 }
Ejemplo n.º 12
0
        public IHttpActionResult Post([FromBody] CincinnatiRegistration goVolunteerRegistration)
        {
            if (ModelState.IsValid)
            {
                return(Authorized(token => SaveRegistration(token, goVolunteerRegistration),
                                  () => SaveRegistration(string.Empty, goVolunteerRegistration)));
            }
            var errors    = ModelState.Values.SelectMany(val => val.Errors).Aggregate("", (current, err) => current + err.ErrorMessage);
            var dataError = new ApiErrorDto("Registration Data Invalid", new InvalidOperationException("Invalid Registration Data" + errors));

            throw new HttpResponseException(dataError.HttpResponseMessage);
        }
Ejemplo n.º 13
0
 private IHttpActionResult SaveRegistration(string token, CincinnatiRegistration goVolunteerRegistration)
 {
     try
     {
         var reg = _goVolunteerService.CreateRegistration(goVolunteerRegistration, token);
         return(Ok(reg));
     }
     catch (Exception e)
     {
         var msg = "GoVolunteerRegistrationController: POST " + goVolunteerRegistration;
         logger.Error(msg, e);
         var apiError = new ApiErrorDto(msg, e);
         throw new HttpResponseException(apiError.HttpResponseMessage);
     }
 }
Ejemplo n.º 14
0
        private int CreateRegistration(CincinnatiRegistration registration, int participantId)
        {
            var registrationDto = new MpRegistration {
                ParticipantId = participantId
            };
            var preferredLaunchSiteId = PreferredLaunchSite(registration);

            registrationDto.AdditionalInformation = registration.AdditionalInformation;
            registrationDto.InitiativeId          = registration.InitiativeId;
            registrationDto.OrganizationId        = registration.OrganizationId;
            registrationDto.OtherOrganizationName = registration.OtherOrganizationName;
            registrationDto.PreferredLaunchSiteId = preferredLaunchSiteId;
            registrationDto.RoleId = registration.RoleId;
            registrationDto.SpouseParticipation = registration.SpouseParticipation;
            return(Registration(registrationDto));
        }
Ejemplo n.º 15
0
        private List <HtmlElement> SpouseDetails(CincinnatiRegistration registration)
        {
            var spouse = new List <HtmlElement>()
            {
                BuildParagraph("Spouse Name: ", registration.Spouse.FirstName + " " + registration.Spouse.LastName),
            };

            if (registration.Spouse.EmailAddress != null)
            {
                spouse.Add(BuildParagraph("Spouse Email: ", registration.Spouse.EmailAddress));
            }
            if (registration.Spouse.MobilePhone != null)
            {
                spouse.Add(BuildParagraph("Spouse Mobile Phone: ", registration.Spouse.MobilePhone));
            }
            return(spouse);
        }
Ejemplo n.º 16
0
 private List <HtmlElement> ChildrenDetails(CincinnatiRegistration registration)
 {
     return(registration.ChildAgeGroup.Select(c =>
     {
         if (c.Id == _configurationWrapper.GetConfigIntValue("Children2To7") && c.Count > 0)
         {
             return BuildParagraph("Number of Children Ages 2-7: ", c.Count.ToString());
         }
         else if (c.Id == _configurationWrapper.GetConfigIntValue("Children8To12") && c.Count > 0)
         {
             return BuildParagraph("Number of Children Ages 8-12: ", c.Count.ToString());
         }
         else if (c.Id == _configurationWrapper.GetConfigIntValue("Children13To18") && c.Count > 0)
         {
             return BuildParagraph("Number of Children Ages 13-18: ", c.Count.ToString());
         }
         return new HtmlElement("p");
     }).ToList());
 }
Ejemplo n.º 17
0
        public CincinnatiRegistration CreateRegistration(CincinnatiRegistration registration, string token)
        {
            try
            {
                var participantId  = RegistrationContact(registration, token);
                var registrationId = CreateRegistration(registration, participantId);

                var asyncTasks = Observable.CombineLatest(
                    Observable.Start(() => GroupConnector(registration, registrationId)),
                    Observable.Start(() => _skillsService.UpdateSkills(participantId, registration.Skills, token)),
                    Observable.Start(() => Attributes(registration, registrationId))
                    );

                if (registration.SpouseParticipation)
                {
                    var spouse = Observable.Start <MpContact>(() => SpouseInformation(registration));
                    spouse.Subscribe(contact =>
                    {
                        if (contact != null)
                        {
                            registration.Spouse.ContactId    = contact.ContactId;
                            registration.Spouse.EmailAddress = contact.EmailAddress;
                        }
                        Observable.Start(() => SendMail(registration));
                    });
                }
                else
                {
                    Observable.Start(() => SendMail(registration));
                }

                return(registration);
            }
            catch (Exception ex)
            {
                const string msg = "Go Volunteer Service: CreateRegistration";
                _logger.Error(msg, ex);
                throw new Exception(msg, ex);
            }
        }
Ejemplo n.º 18
0
        private List <HtmlElement> GroupConnectorDetails(CincinnatiRegistration registration)
        {
            var ret = new List <HtmlElement>();

            if (!registration.CreateGroupConnector)
            {
                ret.Add(BuildParagraph("Group Connector: ", registration.GroupConnector.Name));
                if (registration.GroupConnector.ProjectType != null)
                {
                    ret.Add(BuildParagraph("Project Type: ", registration.GroupConnector.ProjectType));
                }
                ret.Add(BuildParagraph("Preferred Launch Site: ", registration.GroupConnector.PreferredLaunchSite));
            }
            else
            {
                ret.Add(BuildParagraph("Preferred Launch Site: ", registration.PreferredLaunchSite.Name));
                ret.Add(BuildParagraph("Project Preference 1: ", registration.ProjectPreferences[0].Name));
                ret.Add(BuildParagraph("Project Preference 2: ", registration.ProjectPreferences[1].Name));
                ret.Add(BuildParagraph("Project Preference 3: ", registration.ProjectPreferences[2].Name));
            }

            return(ret);
        }