示例#1
0
        public async Task <string> Handle(SaveRegistrantCommand cmd)
        {
            if (cmd.Profile.SecurityQuestions.Count() > 3)
            {
                throw new Exception($"Registrant can have a max of 3 Security Questions");
            }
            var contact = mapper.Map <Contact>(cmd.Profile);
            var result  = await contactRepository.ManageContact(new SaveContact { Contact = contact });

            var updatedQuestions = mapper.Map <IEnumerable <Resources.Contacts.SecurityQuestion> >(cmd.Profile.SecurityQuestions.Where(s => s.AnswerChanged));

            if (updatedQuestions.Count() > 0)
            {
                await contactRepository.ManageContact(new UpdateSecurityQuestions { ContactId = result.ContactId, SecurityQuestions = updatedQuestions });
            }

            if (string.IsNullOrEmpty(cmd.Profile.Id))
            {
                //send email when creating a new registrant profile
                if (contact.Email != null)
                {
                    await SendEmailNotification(
                        SubmissionTemplateType.newProfileRegistration,
                        email : contact.Email,
                        name : $"{contact.LastName}, {contact.FirstName}",
                        tokens : Array.Empty <KeyValuePair <string, string> >());
                }
            }

            return(result.ContactId);
        }
示例#2
0
        public async Task <string> Handle(SaveRegistrantCommand cmd)
        {
            var contact = mapper.Map <Contact>(cmd.Profile);
            var result  = await contactRepository.ManageContact(new SaveContact { Contact = contact });

            if (string.IsNullOrEmpty(cmd.Profile.Id))
            {
                //send email when creating a new registrant profile
                if (contact.Email != null)
                {
                    await SendEmailNotification(
                        SubmissionTemplateType.NewProfileRegistration,
                        email : contact.Email,
                        name : $"{contact.LastName}, {contact.FirstName}",
                        tokens : Array.Empty <KeyValuePair <string, string> >());
                }
            }

            return(result.ContactId);
        }