Ejemplo n.º 1
0
        public void TestMethod1()
        {
            var deserializer = new TestDataDeserializer();

            var allDeacons = deserializer.DeserializeMembersTestData();

            Assert.IsTrue(allDeacons.Count > 0);
        }
Ejemplo n.º 2
0
        private void SeedMembers(UnitOfWork db)
        {
            var testDataDeserializer = new TestDataDeserializer();
            var members = testDataDeserializer.DeserializeMembersTestData();

            foreach (var member in members)
            {
                _members.Add(new CCGMember
                {
                    IndividualId    = member.IndividualId.Equals("") ? null : member.IndividualId,
                    FirstName       = member.FirstName,
                    LastName        = member.LastName,
                    Title           = member.Title.Equals("") ? null : member.Title,
                    Suffix          = member.Suffix.Equals("") ? null : member.Suffix,
                    Address         = member.Address.Equals("") ? null : member.Address,
                    City            = member.City,
                    State           = member.State,
                    ZipCode         = member.ZipCode,
                    CellPhoneNumber = member.CellPhone.Equals("") ? null : member.CellPhone,
                    PhoneNumber     = member.HomePhone,
                    EmailAddress    = member.PreferredEmail,
                    FamilyNumber    = member.FamilyNumber.Equals("") ? null : member.FamilyNumber,
                    EnvelopNumber   = member.EnvelopeNumber.Equals("") ? null : member.EnvelopeNumber,
                    BirthDate       = GetRandomBirthDate(),
                    DateJoinedZion  = GetRandomAnniversaryDate(),
                    AnniversaryDate = GetRandomAnniversaryDate(),
                    ZionEntryDate   = member.EntryDate,
                    DateLastChanged = member.DateLastChanged,
                    CcgId           = GetTestCcgId(member.CCG, db),
                });
            }


            // Delete all members
            //var records = db.MemberRepository.FindMembers();
            //foreach (var record in records)
            //{
            //    db.MemberRepository.Delete(record);
            //}
            //db.Commit();


            foreach (var member in _members)
            {
                var dbSet = _dbContext.Set <CCGMember>();

                if (!dbSet.Any(m => (m.FirstName.Equals(member.FirstName) &&
                                     m.LastName.Equals(member.LastName))))
                {
                    dbSet.AddOrUpdate(member);

                    //db.MemberRepository.AddOrUpdate(member);
                }
            }
        }
Ejemplo n.º 3
0
        private void SeedAppUsers(UnitOfWork db)
        {
            var testDataDeserializer = new TestDataDeserializer();
            var testDataDeacons      = testDataDeserializer.DeserializeDeaconsTestData();

            // Get users from external source and add to list.
            foreach (var testDataDeacon in testDataDeacons)
            {
                if (string.IsNullOrEmpty(testDataDeacon.SharepointEmail) ||
                    string.IsNullOrEmpty(testDataDeacon.FamDistrictDeacon))
                {
                    continue;
                }

                var names = GetTestAppUserNames(testDataDeacon.FamDistrictDeacon);
                int?ccgId = GetTestCcgId(testDataDeacon.GroupName, db);

                _appUsers.Add(new CCGAppUser
                {
                    Email        = testDataDeacon.SharepointEmail,
                    UserName     = testDataDeacon.SharepointEmail,
                    LastName     = names["Last Name"],
                    FirstName    = names["First Name"],
                    CcgId        = ccgId,
                    EmailAddress = testDataDeacon.Email,
                    PhoneNumber  = GetRandomPhoneNumber(),
                });
            }

            // Add users to data store
            foreach (var appUser in _appUsers)
            {
                var dbSet = _dbContext.Set <CCGAppUser>();


                using (var userStore = new UserStore <CCGAppUser>(_dbContext))
                    using (var userManager = new ApplicationUserManager(userStore))
                    {
                        // if user exists, update
                        if (dbSet.Any(u => u.UserName.Equals(appUser.UserName)))
                        {
                            var user = userManager.Users.SingleOrDefault(u => u.UserName.Equals(appUser.UserName));
                            user.Email        = appUser.Email;
                            user.UserName     = appUser.UserName;
                            user.LastName     = appUser.LastName;
                            user.FirstName    = appUser.FirstName;
                            user.CcgId        = appUser.CcgId;
                            user.EmailAddress = appUser.EmailAddress;
                            user.PhoneNumber  = appUser.PhoneNumber;

                            _dbContext.Entry(user).State = EntityState.Modified;

                            userManager.Update(user);
                        }
                        else
                        {
                            // else add user
                            if (appUser != null)
                            {
                                userManager.Create(appUser);
                            }
                        }
                    }
            }
        }