Example #1
0
        public async Task <IActionResult> Edit(long id, [Bind("PersonEmailId,PersonId,EmailAddress")] PersonEmail personEmail)
        {
            if (id != personEmail.PersonEmailId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(personEmail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonEmailExists(personEmail.PersonEmailId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "Clients", new { id = personEmail.PersonId }, null));
            }
            ViewData["PersonId"] = new SelectList(_context.Persons, "PersonId", "FirstName", personEmail.PersonId);
            return(View(personEmail));
        }
        public async Task <object> PostPersonEmail(PersonEmail checkEmail)
        {
            bool flag = isEmail(checkEmail.Email);

            dynamic cResponse = new ExpandoObject();

            if (!String.IsNullOrEmpty(checkEmail.Email) && flag)
            {
                int count = await db.Person.CountAsync(x => x.Email == checkEmail.Email);

                if (count > 0)
                {
                    cResponse.Result      = "-1";
                    cResponse.Description = "Email is not available";
                    cResponse.Email       = checkEmail.Email;
                    return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse)));
                }
                else
                {
                    cResponse.Result      = "0";
                    cResponse.Description = "Email is available";
                    cResponse.Email       = checkEmail.Email;
                    return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse)));
                }
            }
            else
            {
                cResponse.Result      = "-1";
                cResponse.Description = "Email format is wrong";
                cResponse.Email       = checkEmail.Email;
                return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse)));
            }
        }
Example #3
0
        private async void VerifyUserEmailAsync(ApplicationUser user)
        {
            //Verify email address is confirmed with identity
            var emailConfirmed = userManager.IsEmailConfirmedAsync(user).Result;

            if (!emailConfirmed)
            {
                string emailVerificationToken = userManager.GenerateEmailConfirmationTokenAsync(user).Result;
                var    result = userManager.ConfirmEmailAsync(user, emailVerificationToken).Result;

                if (result.Succeeded)
                {
                    var emailVerification = emailVerificationRepository.Find(null, p => p.PersonId == user.PersonId && p.IsVerified != true)?.Items?.FirstOrDefault();
                    if (emailVerification != null)
                    {
                        var verifiedEmailAddress = personEmailRepository.Find(null, p => p.Address.Equals(emailVerification.Address, StringComparison.OrdinalIgnoreCase))?.Items?.FirstOrDefault();
                        if (verifiedEmailAddress == null)
                        {
                            var personEmail = new PersonEmail()
                            {
                                EmailVerificationId = emailVerification.Id,
                                IsPrimaryEmail      = true,
                                PersonId            = emailVerification.PersonId,
                                Address             = emailVerification.Address
                            };
                            personEmailRepository.Add(personEmail);
                        }

                        //Verification completed
                        emailVerification.IsVerified = true;
                        emailVerificationRepository.Update(emailVerification);
                    }
                }
            }
        }
Example #4
0
        private void Setting_OnClick(object sender, RoutedEventArgs e)
        {
            _newEmailPerson = new EmailLogin(_newEmailer);

            _newEmailPerson.ShowDialog();

            if (!string.IsNullOrEmpty(_newEmailPerson.EmailUser))
            {
            }

            try
            {
                _newEmailer = new PersonEmail(_newEmailPerson.EmailUser, _newEmailPerson.EmailPass)
                {
                    SendingTo = _newEmailPerson.SendToEmail
                };

                if (_newEmailPerson.WillSerialize)
                {
                    SerializeEmail(_newEmailer, _emailInfo);
                }

                _emailer = new EmailProcess(_newEmailer.EmailAddress, _newEmailer.Password, _newEmailer.SendingTo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Email information was not entered", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public static Person GetPersonWithoutId()
 {
     return(new Person(
                surrogateId: Option.None <string>(),
                firstName: PersonFirstName.Create("firstname").Value,
                name: PersonName.Create("name").Value,
                email: PersonEmail.Create("*****@*****.**").Value));
 }
 public static Person ToBusinessObject(this CreatePersonModel model)
 {
     return new Person(
         surrogateId: Option.None<string>(),
         firstName: PersonFirstName.Create(model.FirstName).Value,
         name: PersonName.Create(model.Name).Value,
         email: PersonEmail.Create(model.Email).Value);
 }
 public static Person ToBusiness(this PersonEntity personEntity)
 {
     return(new Person(
                surrogateId: Option.Some(personEntity.Id),
                firstName: PersonFirstName.Create(personEntity.FirstName).Value,
                name: PersonName.Create(personEntity.Name).Value,
                email: PersonEmail.Create(personEntity.Email).Value));
 }
Example #8
0
        public void EmailShouldCanBeEmpty()
        {
            var stringEmail = "";

            var email = PersonEmail.Create(stringEmail);

            Check.That(email.IsSuccess).IsTrue();
        }
        public static Result Evaluate(this CreatePersonModel model)
        {
            var firstName = PersonFirstName.Create(model.FirstName);
            var name = PersonName.Create(model.Name);
            var email = PersonEmail.Create(model.Email);

            return Result.Combine(firstName, name, email);
        }
Example #10
0
 private Person GetDefaultPerson()
 {
     return(new Person(
                Option.None <string>(),
                firstName: PersonFirstName.Create("firstname").Value,
                name: PersonName.Create("name").Value,
                email: PersonEmail.Create("*****@*****.**").Value
                ));
 }
Example #11
0
        public void EmailShouldBeEqualsToSameEmail()
        {
            var stringEmail = "";
            var email2      = PersonEmail.Create(stringEmail).Value;

            var email = PersonEmail.Create(stringEmail).Value;

            Check.That(email).IsEqualTo(email2);
        }
Example #12
0
        public async Task <IActionResult> Create([Bind("PersonEmailId,PersonId,EmailAddress")] PersonEmail personEmail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(personEmail);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Clients", new { id = personEmail.PersonId }, null));
            }
            ViewData["PersonId"] = new SelectList(_context.Persons, "PersonId", "FirstName", personEmail.PersonId);
            return(View(personEmail));
        }
Example #13
0
        public EmailLogin(PersonEmail savedEmail)
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            //load user info
            UsernameTxt.Text     = savedEmail.EmailAddress;
            PasswordTxt.Password = savedEmail.Password;
            SendToTxt.Text       = savedEmail.SendingTo;

            SaveLoginInfo.IsChecked = true;
        }
Example #14
0
        public async Task <IActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                ModelState.AddModelError("ConfirmEmail", "UserId / Code missing");
                return(BadRequest(ModelState));
            }
            IdentityResult result;

            try
            {
                applicationUser = userManager.FindByIdAsync(userId).Result;
                if (applicationUser == null)
                {
                    return(Redirect(string.Format("{0}{1}", configuration["WebAppUrl:Url"], configuration["WebAppUrl:NoUserExists"])));
                }
                result = await userManager.ConfirmEmailAsync(applicationUser, code);
            }
            catch (InvalidOperationException ioe)
            {
                // ConfirmEmailAsync throws when the userId is not found.
                return(ioe.GetActionResult());
            }

            if (result.Succeeded)
            {
                var emailVerification = emailVerificationRepository.Find(null, p => p.PersonId == applicationUser.PersonId && p.IsVerified != true)?.Items?.FirstOrDefault();
                if (emailVerification != null)
                {
                    var verifiedEmailAddress = personEmailRepository.Find(null, p => p.Address.Equals(emailVerification.Address, StringComparison.OrdinalIgnoreCase))?.Items?.FirstOrDefault();
                    if (verifiedEmailAddress == null)
                    {
                        var personEmail = new PersonEmail()
                        {
                            EmailVerificationId = emailVerification.Id,
                            IsPrimaryEmail      = true,
                            PersonId            = emailVerification.PersonId,
                            Address             = emailVerification.Address
                        };
                        personEmailRepository.Add(personEmail);
                    }

                    //Verification completed
                    emailVerification.IsVerified = true;
                    emailVerificationRepository.Update(emailVerification);
                }

                return(Redirect(string.Format("{0}{1}", configuration["WebAppUrl:Url"], configuration["WebAppUrl:login"])));
            }

            // If we got this far, something failed.
            return(Redirect(string.Format("{0}{1}", configuration["WebAppUrl:Url"], configuration["WebAppUrl:tokenerror"])));
        }
Example #15
0
 private static void SerializeEmail(PersonEmail savedEmail, string fileName)
 {
     try
     {
         using (Stream stream = File.Open(fileName, FileMode.Create))
         {
             BinaryFormatter bin = new BinaryFormatter();
             bin.Serialize(stream, savedEmail);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        public void EmailShouldBeTheSameAsConstructorParameter()
        {
            //Init
            var firstName = Option.None <PersonFirstName>();
            var name      = Option.None <PersonName>();
            var email     = PersonEmail.Create("*****@*****.**").Value;

            //Act
            var person = GetPerson(firstName, name, email);

            //Assert
            var expectedEmail = PersonEmail.Create("*****@*****.**").Value;

            Check.That(person.Email.ValueOrFailure()).IsEqualTo(expectedEmail.ValueOrFailure());
        }
        public void FirstNameShouldNotBeNull()
        {
            PersonFirstName firstName = null;

            Action action = () =>
            {
                new Person(
                    surrogateId: Option.None <string>(),
                    firstName: firstName,
                    name: PersonName.Create("name").Value,
                    email: PersonEmail.Create("*****@*****.**").Value
                    );
            };

            Check.ThatCode(action).Throws <ArgumentException>();
        }
        /// <summary>
        /// Method to try to find an existing person given an exact match with:
        ///   * email address
        ///   * first name
        ///   * last name
        ///   * birthdate
        /// </summary>
        /// <param name="person"></param>
        private void TryFindExistingPerson()
        {
            PersonCollection people = new PersonCollection();

            if (!string.IsNullOrEmpty(this.tbFirstName.Text) && !string.IsNullOrEmpty(this.tbLastName.Text) && !string.IsNullOrEmpty(this.tbBirthDate.Text.Trim()))
            {
                DateTime birthdate = DateTime.Parse(this.tbBirthDate.Text);
                people.LoadByNameAndBirthdate(this.tbFirstName.Text.Trim(), this.tbLastName.Text.Trim(), birthdate);

                foreach (Person p in people)
                {
                    PersonEmail email = p.Emails.FindByEmail(this.tbEmail.Text);
                    if (email != null)
                    {
                        this.person = p;
                        return;
                    }
                }
            }
        }
Example #19
0
        public Email GetPersonPrimaryEmail(int id)
        {
            var retEmail = new Email();
            var person   = new Arena.Core.Person(id);

            if (person.Emails.Active.Count > 0)
            {
                // Get the person's first active email
                PersonEmail email = person.Emails.Active[0];
                foreach (PersonEmail eml in person.Emails.Active)
                {
                    // Now just make sure we have the one with the lowest order
                    if (eml.Order < email.Order)
                    {
                        email = eml;
                    }
                }
                retEmail.Address = email.Email.ToString();
            }
            return(retEmail);
        }
Example #20
0
        private Person PopulatePerson(IDictionary <string, object> result, string createdBy)
        {
            DateTime facebookBirthdate;
            DateTime userSuppliedBirthdate;
            var      lookupID = CurrentOrganization.Settings["CentralAZ.Web.FacebookRegistration.MembershipStatus"];

            if (!DateTime.TryParse(result["birthday"].ToString(), out facebookBirthdate))
            {
                facebookBirthdate = new DateTime(1900, 1, 1);
            }

            if (!DateTime.TryParse(tbBirthdate.Text, out userSuppliedBirthdate))
            {
                userSuppliedBirthdate = new DateTime(1900, 1, 1);
            }

            var person = new Person
            {
                FirstName    = result["first_name"].ToString(),
                LastName     = result["last_name"].ToString(),
                RecordStatus = RecordStatus.Pending,
                MemberStatus = new Lookup(int.Parse(lookupID)),
                BirthDate    = (facebookBirthdate != userSuppliedBirthdate && userSuppliedBirthdate != new DateTime(1900, 1, 1))
                                         ? userSuppliedBirthdate
                                         : facebookBirthdate
            };

            // Create new person object, and register an Arena login for them.
            person.Save(CurrentOrganization.OrganizationID, createdBy, false);
            var email = new PersonEmail
            {
                Active        = true,
                AllowBulkMail = true,
                Email         = result["email"].ToString(),
                PersonId      = person.PersonID
            };

            person.Emails.Add(email);
            return(person);
        }
Example #21
0
        private void DeserializeEmail(string fileName)
        {
            if (File.Exists(fileName) == false)
            {
                _isEmailSaved = false;
                return;
            }
            try
            {
                using (Stream stream = File.Open(fileName, FileMode.Open))
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    _newEmailer = (PersonEmail)bin.Deserialize(stream);
                }

                _isEmailSaved = true;
            }
            catch (Exception)
            {
                _isEmailSaved = false;
            }
        }
Example #22
0
        public ClientServiceImplTest()
        {
            this.person = new Person(
                Option.None <string>(),
                PersonFirstName.Create("john").Value,
                PersonName.Create("smith").Value,
                PersonEmail.Create("*****@*****.**").Value);
            this.personQuery = Substitute.For <PersonQuery>();
            this.personQuery.Exist(this.person).Returns(true);

            var mediator = Substitute.For <IMediator>();

            this.personRepository = Substitute.For <PersonRepository>();

            this.accomodation      = AccomodationTest.GetAccomodation();
            this.accomodationQuery = Substitute.For <AccomodationQuery>();
            this.accomodationQuery.Exist(this.accomodation).Returns(true);
            this.personQuery.IsAccomodationSold(this.accomodation).Returns(false);

            this.clientService = new ClientServiceImpl(this.personRepository,
                                                       this.personQuery, this.accomodationQuery, mediator);
        }
Example #23
0
        public async Task <IActionResult> ConfirmEmailAddress(string emailAddress, string token)
        {
            //To decode the token to get the creation time, person Id:
            byte[] data  = Convert.FromBase64String(token);
            byte[] _time = data.Take(8).ToArray();
            byte[] _key  = data.Skip(8).ToArray();

            DateTime when     = DateTime.FromBinary(BitConverter.ToInt64(_time, 0));
            Guid     personId = new Guid(_key);

            if (when < DateTime.UtcNow.AddHours(-24))
            {
                return(Redirect(string.Format("{0}{1}", configuration["WebAppUrl:Url"], configuration["WebAppUrl:tokenerror"])));
            }

            var emailVerification = emailVerificationRepository.Find(null, p => p.PersonId == personId && p.Address.Equals(emailAddress, StringComparison.OrdinalIgnoreCase) && p.IsVerified != true)?.Items?.FirstOrDefault();

            if (emailVerification != null)
            {
                var verifiedEmailAddress = personEmailRepository.Find(null, p => p.Address.Equals(emailVerification.Address, StringComparison.OrdinalIgnoreCase))?.Items?.FirstOrDefault();
                if (verifiedEmailAddress == null)
                {
                    var personEmail = new PersonEmail()
                    {
                        EmailVerificationId = emailVerification.Id,
                        IsPrimaryEmail      = false,
                        PersonId            = emailVerification.PersonId,
                        Address             = emailVerification.Address
                    };
                    personEmailRepository.Add(personEmail);
                }

                //Verification completed
                emailVerification.IsVerified = true;
                emailVerificationRepository.Update(emailVerification);
            }
            return(Redirect(string.Format("{0}{1}", configuration["WebAppUrl:Url"], configuration["WebAppUrl:emailaddressconfirmed"])));
        }
Example #24
0
        public MainWindow()
        {
            InitializeComponent();
            _notifyIcon.Icon              = new Icon(Resource.Hopstarter_Mac_Folders_Windows, 20, 20);
            this.StateChanged            += Window_Minimized;
            _notifyIcon.MouseDoubleClick += Window_Unminimized;



            DeserializeEmail(_emailInfo); //check if saved email login exists

            //with no saved login, prompt user
            if (_isEmailSaved == false)
            {
                _newEmailPerson.ShowDialog();

                _newEmailer = new PersonEmail(_newEmailPerson.EmailUser, _newEmailPerson.EmailPass)
                {
                    SendingTo = _newEmailPerson.SendToEmail
                };

                if (_newEmailPerson.WillSerialize)
                {
                    SerializeEmail(_newEmailer, _emailInfo);
                }
            }


            _emailer = new EmailProcess(_newEmailer.EmailAddress, _newEmailer.Password, _newEmailer.SendingTo);

            DeserializeFolders(_folderInfo); //check if saved folders exist

            FolderListView.ItemsSource = _trackingFolderList;

            FolderListView.Items.Refresh();
        }
Example #25
0
        public void EmailShouldNotHaveAnotherFormatThanEmail(string invalidEmail)
        {
            var email = PersonEmail.Create(invalidEmail);

            Check.That(email.IsFailure).IsTrue();
        }
Example #26
0
        public ActionResult JoineMe(RegistrationViewModel pVM)
        {
            if (ModelState.IsValid)
            {
                Person p = new Person()
                {
                    CreatedOn    = DateTime.Now,
                    DOB          = pVM.DateOfBirth.Value,
                    Fname        = pVM.FirstName,
                    Mname        = pVM.MiddleName,
                    Lname        = pVM.LastName,
                    IsActive     = false,
                    GenderId     = Int16.Parse(pVM.Gender),
                    SalutationId = 1,
                    IPaddress    = GetUserIp()
                };

                PersonEmail pe = new PersonEmail()
                {
                    Type = new EmailType()
                    {
                        Id = 1, Name = "PERSONAL"
                    },
                    Value = pVM.PrimaryEmail
                };

                PersonPhone ph = new PersonPhone()
                {
                    Type = new PhoneType()
                    {
                        Id = 1, Name = "MOBILE"
                    },
                    Value = pVM.PhoneNumber
                };

                int newPersonId = cDal.SavePerson(p);

                int newPersonEmailId = cDal.SavePersonEmail(newPersonId, pe);

                int newPersonPhoneId = cDal.SavePersonPhone(newPersonId, ph);

                sDal.LogMe("TRACKING", "NEW JOINEE REQUEST HAS BEEN RECEIVED", newPersonId);

                try
                {
                    var code = sDal.RaisePersonSecurityRequest(newPersonId, "JOINING");

                    string verificationLink = string.Format("http://{0}/verify/{1}", System.Web.HttpContext.Current.Request.Url.Authority, code);

                    Dictionary <string, string> param = new Dictionary <string, string>();
                    param.Add("NAME", $"{pVM.FirstName} {pVM.LastName}");
                    param.Add("VERIFICATIONLINK", verificationLink);

                    string html = bgService.GetHtml(AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["mxTemplatePath"] + "tmpjoining.html", param);

                    var mxType = lookupDal.GetAllMailoutType().Where(x => x.Id == 1).FirstOrDefault();

                    var q = mxDAL.PushNotification(cDal.GetPersonByPersonId(newPersonId), param, mxType.Id, pVM.PrimaryEmail, html);

                    var res = emailService.EmailBySMTP(pVM.PrimaryEmail, ConfigurationManager.AppSettings["SMTP_FROM"], html, mxType.Subject);

                    if (res.HasError)
                    {
                        sDal.LogMe("EMAILEXCEPTION", $"EMAIL EXCEPTION: {res.ErrorMessage}", newPersonId);

                        mxDAL.UpdateNotification(q.Id);
                    }
                }
                catch (Exception ex)
                {
                    sDal.LogMe("EXCEPTION", ex.InnerException.Message, p.Id);
                }

                return(RedirectToAction("ThankYouForJoining", new { Name = pVM.FirstName, EmailAddress = pVM.PrimaryEmail }));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        private void CreateAccount()
        {
            Arena.Security.Login login = new Arena.Security.Login(this.tbLoginID.Text);
            if (login.PersonID != -1)
            {
                int    num  = 0;
                string text = this.tbFirstName.Text.Substring(0, 1).ToLower() + this.tbLastName.Text.Trim().ToLower();
                if (text != this.tbLoginID.Text.Trim().ToLower())
                {
                    login = new Arena.Security.Login(text);
                }
                while (login.PersonID != -1)
                {
                    num++;
                    login = new Arena.Security.Login(text + num.ToString());
                }
                this.lblMessage.Text    = "The Desired Login ID you selected is already in use in our system.  Please select a different Login ID.  Suggestion: <b>" + text + num.ToString() + "</b>";
                this.pnlMessage.Visible = true;
                this.lblMessage.Visible = true;
                return;
            }
            Lookup lookup;

            try
            {
                lookup = new Lookup(int.Parse(this.MemberStatusIDSetting));
                if (lookup.LookupID == -1)
                {
                    throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Member Status setting must be a valid Member Status Lookup value.");
                }
            }
            catch (System.Exception inner)
            {
                throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Member Status setting must be a valid Member Status Lookup value.", inner);
            }
            int    organizationID = base.CurrentPortal.OrganizationID;
            string text2          = base.CurrentUser.Identity.Name;

            if (text2 == string.Empty)
            {
                text2 = "NewAccount.ascx";
            }
            Person person = new Person();

            person.RecordStatus = RecordStatus.Pending;
            person.MemberStatus = lookup;
            if (ddlCampus.SelectedValue != string.Empty || this.CampusSetting != string.Empty)
            {
                // use the user set value if it exists, otherwise use the admin configured module setting
                string campusString = (ddlCampus.SelectedValue != string.Empty) ? ddlCampus.SelectedValue : this.CampusSetting;
                try
                {
                    person.Campus = new Campus(int.Parse(campusString));
                }
                catch
                {
                    person.Campus = null;
                }
            }
            person.FirstName = this.tbFirstName.Text.Trim();
            person.LastName  = this.tbLastName.Text.Trim();
            if (this.tbBirthDate.Text.Trim() != string.Empty)
            {
                try
                {
                    person.BirthDate = DateTime.Parse(this.tbBirthDate.Text);
                }
                catch
                {
                }
            }
            if (this.ddlMaritalStatus.SelectedValue != string.Empty)
            {
                person.MaritalStatus = new Lookup(int.Parse(this.ddlMaritalStatus.SelectedValue));
            }
            if (this.ddlGender.SelectedValue != string.Empty)
            {
                try
                {
                    person.Gender = (Gender)Enum.Parse(typeof(Gender), this.ddlGender.SelectedValue);
                }
                catch
                {
                }
            }
            PersonAddress personAddress = new PersonAddress();

            personAddress.Address     = new Address(this.tbStreetAddress.Text.Trim(), string.Empty, this.tbCity.Text.Trim(), this.ddlState.SelectedValue, this.tbZipCode.Text.Trim(), false);
            personAddress.AddressType = new Lookup(SystemLookup.AddressType_Home);
            personAddress.Primary     = true;
            person.Addresses.Add(personAddress);
            PersonPhone personPhone = new PersonPhone();

            personPhone.Number    = this.tbHomePhone.PhoneNumber.Trim();
            personPhone.PhoneType = new Lookup(SystemLookup.PhoneType_Home);
            person.Phones.Add(personPhone);
            if (this.tbWorkPhone.PhoneNumber.Trim() != string.Empty)
            {
                personPhone           = new PersonPhone();
                personPhone.Number    = this.tbWorkPhone.PhoneNumber.Trim();
                personPhone.Extension = this.tbWorkPhone.Extension;
                personPhone.PhoneType = new Lookup(SystemLookup.PhoneType_Business);
                person.Phones.Add(personPhone);
            }
            if (this.tbCellPhone.PhoneNumber.Trim() != string.Empty)
            {
                personPhone            = new PersonPhone();
                personPhone.Number     = this.tbCellPhone.PhoneNumber.Trim();
                personPhone.PhoneType  = new Lookup(SystemLookup.PhoneType_Cell);
                personPhone.SMSEnabled = this.cbSMS.Checked;
                person.Phones.Add(personPhone);
            }
            if (this.tbEmail.Text.Trim() != string.Empty)
            {
                PersonEmail personEmail = new PersonEmail();
                personEmail.Active = true;
                personEmail.Email  = this.tbEmail.Text.Trim();
                person.Emails.Add(personEmail);
            }
            person.Save(organizationID, text2, false);
            person.SaveAddresses(organizationID, text2);
            person.SavePhones(organizationID, text2);
            person.SaveEmails(organizationID, text2);
            Family family = new Family();

            family.OrganizationID = organizationID;
            family.FamilyName     = this.tbLastName.Text.Trim() + " Family";
            family.Save(text2);
            new FamilyMember(family.FamilyID, person.PersonID)
            {
                FamilyID   = family.FamilyID,
                FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult)
            }.Save(text2);
            Arena.Security.Login login2 = new Arena.Security.Login();
            login2.PersonID = person.PersonID;
            login2.LoginID  = this.tbLoginID.Text.Trim();
            login2.Password = this.tbPassword.Text.Trim();
            if (bool.Parse(this.EmailVerificationSetting))
            {
                login2.Active = false;
            }
            else
            {
                login2.Active = true;
            }
            login2.Save(text2);
            login2 = new Arena.Security.Login(login2.LoginID);
            if (bool.Parse(this.EmailVerificationSetting))
            {
                NewUserAccountEmailVerification newUserAccountEmailVerification = new NewUserAccountEmailVerification();
                Dictionary <string, string>     dictionary = new Dictionary <string, string>();
                dictionary.Add("##FirstName##", person.FirstName);
                dictionary.Add("##LastName##", person.LastName);
                dictionary.Add("##Birthdate##", person.BirthDate.ToShortDateString());
                dictionary.Add("##MaritalStatus##", person.MaritalStatus.Value);
                dictionary.Add("##Gender##", person.Gender.ToString());
                dictionary.Add("##StreetAddress##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.StreetLine1 : "N/A");
                dictionary.Add("##City##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.City : "N/A");
                dictionary.Add("##State##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.State : "N/A");
                dictionary.Add("##ZipCode##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.PostalCode : "N/A");
                dictionary.Add("##HomePhone##", this.tbHomePhone.PhoneNumber);
                dictionary.Add("##WorkPhone##", this.tbWorkPhone.PhoneNumber);
                dictionary.Add("##CellPhone##", this.tbCellPhone.PhoneNumber);
                dictionary.Add("##Login##", this.tbLoginID.Text);
                dictionary.Add("##Password##", this.tbPassword.Text);
                dictionary.Add("##VerificationURL##", string.Format(base.CurrentOrganization.Url + (base.CurrentOrganization.Url.EndsWith("/") ? "" : "/") + "default.aspx?page={0}&pid={1}&un={2}&org={3}&h={4}", new object[]
                {
                    string.IsNullOrEmpty(this.NewUserVerificationPageSetting) ? "" : this.NewUserVerificationPageSetting,
                    person.PersonID.ToString(),
                    login2.LoginID,
                    base.CurrentOrganization.OrganizationID.ToString(),
                    this.CreateHash(login2.PersonID.ToString() + login2.DateCreated.ToString() + login2.LoginID)
                }));
                newUserAccountEmailVerification.Send(person.Emails.FirstActive, dictionary, login2.PersonID);
            }
            else
            {
                FormsAuthentication.SetAuthCookie(login2.LoginID, false);
                base.Response.Cookies["portalroles"].Value = string.Empty;
            }
            if (this.ProfileIDSetting != string.Empty)
            {
                int profileId = -1;
                int lookupID  = -1;
                int lookupID2 = -1;
                try
                {
                    if (this.ProfileIDSetting.Contains("|"))
                    {
                        profileId = int.Parse(this.ProfileIDSetting.Split(new char[]
                        {
                            '|'
                        })[1]);
                    }
                    else
                    {
                        profileId = int.Parse(this.ProfileIDSetting);
                    }
                    lookupID  = int.Parse(this.SourceLUIDSetting);
                    lookupID2 = int.Parse(this.StatusLUIDSetting);
                }
                catch (System.Exception inner2)
                {
                    throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "If using a ProfileID setting for the NewAccount module, then a valid numeric 'ProfileID', 'SourceLUID', and 'StatusLUID' setting must all be used!", inner2);
                }
                Profile profile = new Profile(profileId);
                Lookup  lookup2 = new Lookup(lookupID);
                Lookup  lookup3 = new Lookup(lookupID2);
                if (profile.ProfileID == -1 || lookup2.LookupID == -1 || lookup3.LookupID == -1)
                {
                    throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "'ProfileID', 'SourceLUID', and 'StatusLUID' must all be valid IDs");
                }
                ProfileMember profileMember = new ProfileMember();
                profileMember.ProfileID   = profile.ProfileID;
                profileMember.PersonID    = person.PersonID;
                profileMember.Source      = lookup2;
                profileMember.Status      = lookup3;
                profileMember.DatePending = DateTime.Now;
                profileMember.Save(text2);
                if (profile.ProfileType == ProfileType.Serving)
                {
                    ServingProfile servingProfile = new ServingProfile(profile.ProfileID);
                    new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID)
                    {
                        HoursPerWeek = servingProfile.DefaultHoursPerWeek
                    }.Save();
                }
            }
            string text3 = base.Session["RedirectValue"].ToString();

            if (!string.IsNullOrEmpty(text3))
            {
                base.Session["RedirectValue"] = null;
                base.Response.Redirect(text3);
            }
        }
Example #28
0
        public void EmailShouldBeWellFormed(string validEmail)
        {
            var email = PersonEmail.Create(validEmail);

            Check.That(email.IsSuccess).IsTrue();
        }
Example #29
0
        public static void Initialize(ClinicContext context)
        {
            context.Database.EnsureCreated();

            // Populate species
            if (context.Species.Any())
            {
                return;
            }

            var species = new Species[]
            {
                new Species {
                    Code = "CANINE", Name = "Canine", Description = "Canine"
                },
                new Species {
                    Code = "FELINE", Name = "Feline", Description = "Feline"
                }
            };

            foreach (Species s in species)
            {
                context.Species.Add(s);
            }
            context.SaveChanges();

            // Populate EmployeeTypes
            var employeeTypes = new EmployeeType[]
            {
                new EmployeeType {
                    Code = "VET", Name = "Veterinarian", Description = "Veterinarian"
                },
                new EmployeeType {
                    Code = "TECH", Name = "Technician", Description = "Technician"
                },
                new EmployeeType {
                    Code = "ADMIN", Name = "Administration", Description = "Administration"
                }
            };

            foreach (EmployeeType ea in employeeTypes)
            {
                context.EmployeeTypes.Add(ea);
            }
            context.SaveChanges();

            // Populate Employees
            var employees = new Employee[]
            {
                new Employee {
                    FirstName = "Jeanne", LastName = "Sparks", EmployeeTypeId = employeeTypes.Single(ea => ea.Code == "VET").EmployeeTypeId, HireDate = DateTime.Parse("2018-08-01")
                },
                new Employee {
                    FirstName = "Jenny", LastName = "Palmer", EmployeeTypeId = employeeTypes.Single(ea => ea.Code == "TECH").EmployeeTypeId, HireDate = DateTime.Parse("2018-08-01")
                }
            };

            foreach (Employee e in employees)
            {
                context.Employees.Add(e);
            }
            context.SaveChanges();

            // Populate clients
            var clients = new Client[]
            {
                new Client {
                    FirstName = "Chelsea", LastName = "Bridges"
                },
                new Client {
                    FirstName = "Robin", LastName = "Kizer"
                },
                new Client {
                    FirstName = "John", LastName = "Doe"
                },
            };

            foreach (Client c in clients)
            {
                context.Clients.Add(c);
            }
            context.SaveChanges();


            // Populate Addresses
            var addresses = new PersonAddress[]
            {
                new PersonAddress {
                    PersonId = clients.Single(c => c.LastName == "Bridges").PersonId, AddressLine1 = "22 West Blvd.", City = "Lutherville-Timonium", State = "MD", PostalCode = "21093"
                },
                new PersonAddress {
                    PersonId = clients.Single(c => c.LastName == "Kizer").PersonId, AddressLine1 = "123 Main St.", AddressLine2 = "Apt. B", City = "Towson", State = "MD", PostalCode = "21212"
                },
                new PersonAddress {
                    PersonId = clients.Single(c => c.LastName == "Doe").PersonId, AddressLine1 = "123 Main St.", AddressLine2 = "Apt. A", City = "Towson", State = "MD", PostalCode = "21212"
                },
                new PersonAddress {
                    PersonId = employees.Single(e => e.LastName == "Sparks").PersonId, AddressLine1 = "2525 Eastridge Rd.", City = "Lutherville-Timonium", State = "MD", PostalCode = "21093"
                },
                new PersonAddress {
                    PersonId = employees.Single(e => e.LastName == "Palmer").PersonId, AddressLine1 = "55 Westridge Rd.", City = "Lutherville-Timonium", State = "MD", PostalCode = "21093"
                }
            };

            foreach (PersonAddress pa in addresses)
            {
                context.PersonAddresses.Add(pa);
            }
            context.SaveChanges();

            // Populate Phone Numbers
            var phones = new PersonPhone[]
            {
                new PersonPhone {
                    PersonId = clients.Single(c => c.LastName == "Bridges").PersonId, PhoneNumber = "410-123-1234"
                },
                new PersonPhone {
                    PersonId = clients.Single(c => c.LastName == "Bridges").PersonId, PhoneNumber = "410-123-4321"
                },
                new PersonPhone {
                    PersonId = clients.Single(c => c.LastName == "Kizer").PersonId, PhoneNumber = "410-456-1245"
                },
                new PersonPhone {
                    PersonId = clients.Single(c => c.LastName == "Doe").PersonId, PhoneNumber = "410-785-7845"
                },
                new PersonPhone {
                    PersonId = employees.Single(e => e.LastName == "Sparks").PersonId, PhoneNumber = "410-894-8541"
                },
                new PersonPhone {
                    PersonId = employees.Single(e => e.LastName == "Palmer").PersonId, PhoneNumber = "410-785-7421"
                }
            };

            foreach (PersonPhone pp in phones)
            {
                context.PersonPhones.Add(pp);
            }
            context.SaveChanges();

            // Populate Emails
            var emails = new PersonEmail[]
            {
                new PersonEmail {
                    PersonId = clients.Single(c => c.LastName == "Bridges").PersonId, EmailAddress = "*****@*****.**"
                },
                new PersonEmail {
                    PersonId = clients.Single(c => c.LastName == "Kizer").PersonId, EmailAddress = "*****@*****.**"
                },
                new PersonEmail {
                    PersonId = clients.Single(c => c.LastName == "Doe").PersonId, EmailAddress = "*****@*****.**"
                },
                new PersonEmail {
                    PersonId = employees.Single(e => e.LastName == "Sparks").PersonId, EmailAddress = "*****@*****.**"
                },
                new PersonEmail {
                    PersonId = employees.Single(e => e.LastName == "Palmer").PersonId, EmailAddress = "*****@*****.**"
                }
            };

            foreach (PersonEmail pe in emails)
            {
                context.PersonEmails.Add(pe);
            }
            context.SaveChanges();

            // Populate Pets
            var pets = new ClientAnimal[]
            {
                new ClientAnimal {
                    ClientId = clients.Single(c => c.LastName == "Bridges").PersonId, Name = "Henry", BirthDate = DateTime.Parse("2018-08-01"), SpeciesId = species.Single(s => s.Code == "CANINE").SpeciesId
                },
                new ClientAnimal {
                    ClientId = clients.Single(c => c.LastName == "Bridges").PersonId, Name = "Mudge", BirthDate = DateTime.Parse("2016-07-11"), SpeciesId = species.Single(s => s.Code == "CANINE").SpeciesId
                },
                new ClientAnimal {
                    ClientId = clients.Single(c => c.LastName == "Bridges").PersonId, Name = "Kitty", BirthDate = DateTime.Parse("2019-06-2"), SpeciesId = species.Single(s => s.Code == "FELINE").SpeciesId
                },
                new ClientAnimal {
                    ClientId = clients.Single(c => c.LastName == "Kizer").PersonId, Name = "Nash", BirthDate = DateTime.Parse("2018-08-01"), SpeciesId = species.Single(s => s.Code == "CANINE").SpeciesId
                },
                new ClientAnimal {
                    ClientId = clients.Single(c => c.LastName == "Doe").PersonId, Name = "Fluffy II", BirthDate = DateTime.Parse("2018-08-01"), SpeciesId = species.Single(s => s.Code == "FELINE").SpeciesId
                }
            };

            foreach (ClientAnimal ca in pets)
            {
                context.ClientAnimals.Add(ca);
            }
            context.SaveChanges();

            // Populate Appointments
            var appointments = new Appointment[]
            {
                new Appointment {
                    ClientAnimalId = pets.Single(p => p.Name == "Nash").ClientAnimalId, EmployeeId = employees.Single(e => e.LastName == "Palmer").PersonId, AppointmentDate = DateTime.Parse("2021-01-06 9:00"), Reason = "Ear cleaning"
                },
                new Appointment {
                    ClientAnimalId = pets.Single(p => p.Name == "Nash").ClientAnimalId, EmployeeId = employees.Single(e => e.LastName == "Sparks").PersonId, AppointmentDate = DateTime.Parse("2021-02-05 9:30"), Reason = "Immunization"
                },
                new Appointment {
                    ClientAnimalId = pets.Single(p => p.Name == "Kitty").ClientAnimalId, EmployeeId = employees.Single(e => e.LastName == "Sparks").PersonId, AppointmentDate = DateTime.Parse("2021-01-05 10:00"), Reason = "Immunization"
                },
                new Appointment {
                    ClientAnimalId = pets.Single(p => p.Name == "Henry").ClientAnimalId, EmployeeId = employees.Single(e => e.LastName == "Palmer").PersonId, AppointmentDate = DateTime.Parse("2021-01-07 14:00"), Reason = "Nail trim"
                },
                new Appointment {
                    ClientAnimalId = pets.Single(p => p.Name == "Mudge").ClientAnimalId, EmployeeId = employees.Single(e => e.LastName == "Palmer").PersonId, AppointmentDate = DateTime.Parse("2021-01-07 14:00"), Reason = "Nail trim"
                }
            };

            foreach (Appointment ap in appointments)
            {
                context.Appointments.Add(ap);
            }
            context.SaveChanges();
        }
        protected int GetPersonIdFromInputData()
        {
            string sFirstName = tbFirstName.Text;
            string sLastName = tbLastName.Text;
            string sEmail = tbEmail.Text;
            string sAddress = tbAddress1.Text;
            string sCity = tbCity.Text;
            string sState = tbState.Text;
            string sZip = tbZip.Text;
            string sPhone = tbPhone.Text;

            PersonCollection personCollection = new PersonCollection();
            personCollection.LoadByEmail(sEmail);

            int iFoundPersonId = -1;
            foreach (Person person in personCollection)
            {
                PersonPhone phoneSearch = new PersonPhone(person.PersonID, FormatPhone(sPhone));

                if ((phoneSearch.PersonID == person.PersonID) && (person.LastName.ToLower() == sLastName.ToLower()))
                {
                    this.currentAddress = person.Addresses.FindByType(41);
                    if(this.currentAddress.Address.PostalCode.Substring(0,5) == sZip )
                    {
                        iFoundPersonId = person.PersonID;
                    }
                }
            }

            if (iFoundPersonId > 0)
            {
                //person in the db
                //easy ride...
            }
            else
            {
                //create the family for the person
                Family family = new Family();
                family.OrganizationID = CurrentArenaContext.Organization.OrganizationID;
                family.FamilyName = sLastName + " Family";

                //add person to the family
                FamilyMember familyMember = new FamilyMember();
                family.FamilyMembers.Add(familyMember);

                //
                // Ensure some of the basics are set correctly.
                //
                if ((familyMember.Campus == null || familyMember.Campus.CampusId == -1) && NewPersonCampusSetting != -1)
                    familyMember.Campus = new Campus(NewPersonCampusSetting);
                if (familyMember.MemberStatus == null || familyMember.MemberStatus.LookupID == -1)
                    familyMember.MemberStatus = new Lookup(NewPersonStatusSetting);
                if (familyMember.RecordStatus == Arena.Enums.RecordStatus.Undefined)
                    familyMember.RecordStatus = Arena.Enums.RecordStatus.Pending;

                //add person to the db
                familyMember.FirstName = sFirstName;
                familyMember.FirstName = sFirstName;
                familyMember.LastName = sLastName;
                familyMember.FamilyRole = new Lookup(new Guid("e410e1a6-8715-4bfb-bf03-1cd18051f815"));
                familyMember.Gender = Arena.Enums.Gender.Unknown;
                familyMember.MaritalStatus = new Lookup(new Guid("9C000CF2-677B-4725-981E-BD555FDAFB30"));

                //add email to db and person to email
                PersonEmail personEmail = new PersonEmail();
                personEmail.Email = sEmail;
                personEmail.Active = true;
                familyMember.Emails.Add(personEmail);

                //add address to db and person to address
                PersonAddress personAddress = new PersonAddress();
                personAddress.Address.StreetLine1 = sAddress;
                personAddress.Address.City = sCity;
                personAddress.Address.State = sState;
                personAddress.Address.PostalCode = sZip;
                personAddress.AddressType = new Lookup(41);
                personAddress.Address.Standardize();
                this.currentAddress = personAddress;
                familyMember.Addresses.Add(personAddress);

                //add phone to db and person to phone
                PersonPhone personPhone = new PersonPhone();
                personPhone.PhoneType = new Lookup(new Guid("f2a0fba2-d5ab-421f-a5ab-0c67db6fd72e"));
                familyMember.Phones.Add(personPhone);
                personPhone.Number = FormatPhone(sPhone);

                //Save All
                family.Save(ModuleUserName);
                familyMember.Save(CurrentOrganization.OrganizationID, ModuleUserName, true);
                familyMember.SaveEmails(CurrentPortal.OrganizationID, ModuleUserName);
                familyMember.SaveAddresses(CurrentPortal.OrganizationID, ModuleUserName);
                familyMember.SavePhones(CurrentPortal.OrganizationID, ModuleUserName);
                familyMember.Save(CurrentUser.Identity.Name);

                iFoundPersonId = familyMember.PersonID;
            }

            return iFoundPersonId;
        }
        private Person PopulatePerson(IDictionary<string, object> result, string createdBy)
        {
            DateTime facebookBirthdate;
            DateTime userSuppliedBirthdate;
            var lookupID = CurrentOrganization.Settings["CentralAZ.Web.FacebookRegistration.MembershipStatus"];

            if (!DateTime.TryParse(result["birthday"].ToString(), out facebookBirthdate))
            {
                facebookBirthdate = new DateTime(1900, 1, 1);
            }

            if (!DateTime.TryParse(tbBirthdate.Text, out userSuppliedBirthdate))
            {
                userSuppliedBirthdate = new DateTime(1900, 1, 1);
            }

            var person = new Person
                             {
                                 FirstName = result["first_name"].ToString(),
                                 LastName = result["last_name"].ToString(),
                                 RecordStatus = RecordStatus.Pending,
                                 MemberStatus = new Lookup(int.Parse(lookupID)),
                                 BirthDate = (facebookBirthdate != userSuppliedBirthdate && userSuppliedBirthdate != new DateTime(1900, 1, 1))
                                         ? userSuppliedBirthdate
                                         : facebookBirthdate
                             };

            // Create new person object, and register an Arena login for them.
            person.Save(CurrentOrganization.OrganizationID, createdBy, false);
            var email = new PersonEmail
                            {
                                Active = true,
                                AllowBulkMail = true,
                                Email = result["email"].ToString(),
                                PersonId = person.PersonID
                            };

            person.Emails.Add(email);
            return person;
        }
        public void NewSetDelPersonEmailCmdletTest()
        {
            if (IsTestSite)
            {
                PersonEmail newPersonEmailResponse = null;
                PersonEmail setPersonEmailResponse = null;

                var testEmail        = "*****@*****.**";
                var testUpdatedEmail = "*****@*****.**";

                var newResponse = RunScript <PersonEmail>(
                    "New-SntEnrPersonEmail",
                    new Dictionary <string, object>()
                {
                    { "Email", testEmail },
                    { "EmailType", "01" },
                    { "Owner", new Person()
                      {
                          ID = 1
                      } }
                }
                    );

                if (newResponse.Count == 1)
                {
                    newPersonEmailResponse = newResponse[0];
                }

                // Has been created
                Assert.IsTrue(
                    newPersonEmailResponse != null &&
                    newPersonEmailResponse.Email == testEmail
                    );


                var setResponse = RunScript <PersonEmail>(
                    "Set-SntEnrPersonEmail",
                    new Dictionary <string, object>()
                {
                    { "PersonEmail", newPersonEmailResponse },
                    { "Email", testUpdatedEmail }
                }
                    );
                if (setResponse.Count == 1)
                {
                    setPersonEmailResponse = setResponse[0];
                }

                // Is updated
                Assert.IsTrue(
                    setPersonEmailResponse != null &&
                    setPersonEmailResponse.Email == testUpdatedEmail
                    );


                RunScript <PersonEmail>(
                    "Remove-SntEnrPersonEmail",
                    new Dictionary <string, object>()
                {
                    { "PersonEmail", newPersonEmailResponse }
                }
                    );


                var getPersonEmailCmdlet = new GetSntEnrPersonEmail()
                {
                    PersonEmailId = setPersonEmailResponse.ID
                };


                // Is Deleted?
                Assert.ThrowsException <CmdletInvocationException>(() =>
                                                                   RunScript <PersonEmail>(
                                                                       "Get-SntEnrPersonEmail",
                                                                       new Dictionary <string, object>()
                {
                    { "PersonEmailId", setPersonEmailResponse.ID }
                }
                                                                       )
                                                                   );
            }
        }