Ejemplo n.º 1
0
        public void InsertTestData()
        {
            // Avoid polluting the database if there's already something in there.
            if (_context.Locations.Any() ||
                _context.Organizations.Any() ||
                _context.VolunteerTasks.Any() ||
                _context.Campaigns.Any() ||
                _context.Events.Any() ||
                _context.EventSkills.Any() ||
                _context.Skills.Any() ||
                _context.Resources.Any())
            {
                return;
            }

            #region postalCodes
            var existingPostalCode = _context.PostalCodes.ToList();
            _context.PostalCodes.AddRange(GetPostalCodes(existingPostalCode));
            #endregion

            var organizations      = new List <Organization>();
            var organizationSkills = new List <Skill>();
            var locations          = GetLocations();
            var users = new List <ApplicationUser>();
            var volunteerTaskSignups = new List <VolunteerTaskSignup>();
            var events           = new List <Event>();
            var eventSkills      = new List <EventSkill>();
            var campaigns        = new List <Campaign>();
            var volunteerTasks   = new List <VolunteerTask>();
            var resources        = new List <Resource>();
            var contacts         = GetContacts();
            var skills           = new List <Skill>();
            var eventManagers    = new List <EventManager>();
            var campaignManagers = new List <CampaignManager>();

            #region Skills
            var medical = new Skill {
                Name = "Medical", Description = "specific enough, right?"
            };
            var cprCertified = new Skill {
                Name = "CPR Certified", ParentSkill = medical, Description = "ha ha ha ha, stayin alive"
            };
            var md = new Skill {
                Name = "MD", ParentSkill = medical, Description = "Trust me, I'm a doctor"
            };
            var surgeon = new Skill {
                Name = "Surgeon", ParentSkill = md, Description = "cut open; sew shut; play 18 holes"
            };
            skills.AddRange(new[] { medical, cprCertified, md, surgeon });
            #endregion

            #region Organization

            var organization = new Organization
            {
                Name                 = "Humanitarian Toolbox",
                LogoUrl              = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl               = "http://www.htbox.org",
                Location             = locations.FirstOrDefault(),
                Campaigns            = new List <Campaign>(),
                OrganizationContacts = new List <OrganizationContact>(),
            };

            #endregion

            #region Organization Skills

            organizationSkills.Add(new Skill
            {
                Name               = "Code Ninja",
                Description        = "Ability to commit flawless code without review or testing",
                OwningOrganization = organization
            });

            #endregion

            #region Campaign
            //TODO: Campaign/Event/Task dates need to be set as a DateTimeOffset, offset to the correct timezone instead of UtcNow or DateTime.Today.
            var firePreventionCampaign = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = organization,
                Resources            = resources,
                TimeZoneId           = _timeZone.Id,
                StartDateTime        = AdjustToTimezone(DateTimeOffset.Now.AddMonths(-1), _timeZone),
                EndDateTime          = AdjustToTimezone(DateTimeOffset.Now.AddMonths(3), _timeZone),
                Location             = GetRandom(locations),
                Published            = true
            };
            organization.Campaigns.Add(firePreventionCampaign);

            var smokeDetectorCampaignGoal = new CampaignGoal
            {
                GoalType         = GoalType.Numeric,
                NumericGoal      = 10000,
                CurrentGoalLevel = 6722,
                Display          = true,
                TextualGoal      = "Total number of smoke detectors installed."
            };
            _context.CampaignGoals.Add(smokeDetectorCampaignGoal);

            var smokeDetectorCampaign = new Campaign
            {
                Name = "Working Smoke Detectors Save Lives",
                ManagingOrganization = organization,
                StartDateTime        = AdjustToTimezone(DateTime.Today.AddMonths(-1), _timeZone),
                EndDateTime          = AdjustToTimezone(DateTime.Today.AddMonths(1), _timeZone),
                CampaignGoals        = new List <CampaignGoal> {
                    smokeDetectorCampaignGoal
                },
                TimeZoneId = _timeZone.Id,
                Location   = GetRandom(locations),
                Published  = true
            };
            organization.Campaigns.Add(smokeDetectorCampaign);

            var financialCampaign = new Campaign
            {
                Name = "Everyday Financial Safety",
                ManagingOrganization = organization,
                TimeZoneId           = _timeZone.Id,
                StartDateTime        = AdjustToTimezone(DateTime.Today.AddMonths(-1), _timeZone),
                EndDateTime          = AdjustToTimezone(DateTime.Today.AddMonths(1), _timeZone),
                Location             = GetRandom(locations),
                Published            = true
            };
            organization.Campaigns.Add(financialCampaign);

            var safetyKitCampaign = new Campaign
            {
                Name = "Simple Safety Kit Building",
                ManagingOrganization = organization,
                TimeZoneId           = _timeZone.Id,
                StartDateTime        = AdjustToTimezone(DateTime.Today.AddMonths(-1), _timeZone),
                EndDateTime          = AdjustToTimezone(DateTime.Today.AddMonths(2), _timeZone),
                Location             = GetRandom(locations),
                Published            = true
            };
            organization.Campaigns.Add(safetyKitCampaign);

            var carSafeCampaign = new Campaign
            {
                Name = "Family Safety In the Car",
                ManagingOrganization = organization,
                TimeZoneId           = _timeZone.Id,
                StartDateTime        = AdjustToTimezone(DateTime.Today.AddMonths(-1), _timeZone),
                EndDateTime          = AdjustToTimezone(DateTime.Today.AddMonths(2), _timeZone),
                Location             = GetRandom(locations),
                Published            = true
            };
            organization.Campaigns.Add(carSafeCampaign);

            var escapePlanCampaign = new Campaign
            {
                Name = "Be Ready to Get Out: Have a Home Escape Plan",
                ManagingOrganization = organization,
                TimeZoneId           = _timeZone.Id,
                StartDateTime        = AdjustToTimezone(DateTime.Today.AddMonths(-6), _timeZone),
                EndDateTime          = AdjustToTimezone(DateTime.Today.AddMonths(6), _timeZone),
                Location             = GetRandom(locations),
                Published            = true
            };
            organization.Campaigns.Add(escapePlanCampaign);

            #endregion

            #region Event
            var queenAnne = new Event
            {
                Name           = "Queen Anne Fire Prevention Day",
                Campaign       = firePreventionCampaign,
                StartDateTime  = AdjustToTimezone(firePreventionCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime    = AdjustToTimezone(firePreventionCampaign.StartDateTime.AddMonths(2), _timeZone),
                TimeZoneId     = firePreventionCampaign.TimeZoneId,
                Location       = GetRandom(locations),
                RequiredSkills = new List <EventSkill>(),
                EventType      = EventType.Itinerary,
            };
            queenAnne.VolunteerTasks = GetSomeVolunteerTasks(queenAnne, organization);
            var ask = new EventSkill {
                Skill = surgeon, Event = queenAnne
            };
            queenAnne.RequiredSkills.Add(ask);
            eventSkills.Add(ask);
            ask = new EventSkill {
                Skill = cprCertified, Event = queenAnne
            };
            queenAnne.RequiredSkills.Add(ask);
            eventSkills.Add(ask);
            volunteerTasks.AddRange(queenAnne.VolunteerTasks);

            var ballard = new Event
            {
                Name          = "Ballard Fire Prevention Day",
                Campaign      = firePreventionCampaign,
                StartDateTime = AdjustToTimezone(firePreventionCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(firePreventionCampaign.StartDateTime.AddMonths(2), _timeZone),
                TimeZoneId    = firePreventionCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            ballard.VolunteerTasks = GetSomeVolunteerTasks(ballard, organization);
            volunteerTasks.AddRange(ballard.VolunteerTasks);
            var madrona = new Event
            {
                Name          = "Madrona Fire Prevention Day",
                Campaign      = firePreventionCampaign,
                StartDateTime = AdjustToTimezone(firePreventionCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(firePreventionCampaign.StartDateTime.AddMonths(2), _timeZone),
                TimeZoneId    = firePreventionCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            madrona.VolunteerTasks = GetSomeVolunteerTasks(madrona, organization);
            volunteerTasks.AddRange(madrona.VolunteerTasks);
            var southLoopSmoke = new Event
            {
                Name          = "Smoke Detector Installation and Testing-South Loop",
                Campaign      = smokeDetectorCampaign,
                StartDateTime = AdjustToTimezone(smokeDetectorCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(smokeDetectorCampaign.EndDateTime, _timeZone),
                TimeZoneId    = smokeDetectorCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            southLoopSmoke.VolunteerTasks = GetSomeVolunteerTasks(southLoopSmoke, organization);
            volunteerTasks.AddRange(southLoopSmoke.VolunteerTasks);
            var northLoopSmoke = new Event
            {
                Name          = "Smoke Detector Installation and Testing-Near North Side",
                Campaign      = smokeDetectorCampaign,
                StartDateTime = AdjustToTimezone(smokeDetectorCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(smokeDetectorCampaign.EndDateTime, _timeZone),
                TimeZoneId    = smokeDetectorCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            northLoopSmoke.VolunteerTasks = GetSomeVolunteerTasks(northLoopSmoke, organization);
            volunteerTasks.AddRange(northLoopSmoke.VolunteerTasks);
            var dateTimeToday    = DateTime.Today;
            var rentersInsurance = new Event
            {
                Name          = "Renters Insurance Education Door to Door and a bag of chips",
                Description   = "description for the win",
                Campaign      = financialCampaign,
                StartDateTime = AdjustToTimezone(new DateTime(dateTimeToday.Year, dateTimeToday.Month, dateTimeToday.Day, 8, 0, 0), _timeZone),
                EndDateTime   = AdjustToTimezone(new DateTime(dateTimeToday.Year, dateTimeToday.Month, dateTimeToday.Day, 16, 0, 0), _timeZone),
                TimeZoneId    = financialCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Rally,
            };
            rentersInsurance.VolunteerTasks = GetSomeVolunteerTasks(rentersInsurance, organization);
            volunteerTasks.AddRange(rentersInsurance.VolunteerTasks);
            var rentersInsuranceEd = new Event
            {
                Name          = "Renters Insurance Education Door to Door (woop woop)",
                Description   = "another great description",
                Campaign      = financialCampaign,
                StartDateTime = AdjustToTimezone(financialCampaign.StartDateTime.AddMonths(1).AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(financialCampaign.EndDateTime, _timeZone),
                TimeZoneId    = financialCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            rentersInsuranceEd.VolunteerTasks = GetSomeVolunteerTasks(rentersInsuranceEd, organization);
            volunteerTasks.AddRange(rentersInsuranceEd.VolunteerTasks);
            var safetyKitBuild = new Event
            {
                Name          = "Safety Kit Assembly Volunteer Day",
                Description   = "Full day of volunteers building kits",
                Campaign      = safetyKitCampaign,
                StartDateTime = AdjustToTimezone(safetyKitCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(safetyKitCampaign.StartDateTime.AddMonths(1).AddDays(5), _timeZone),
                TimeZoneId    = safetyKitCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            safetyKitBuild.VolunteerTasks = GetSomeVolunteerTasks(safetyKitBuild, organization);
            volunteerTasks.AddRange(safetyKitBuild.VolunteerTasks);

            var safetyKitHandout = new Event
            {
                Name          = "Safety Kit Distribution Weekend",
                Description   = "Handing out kits at local fire stations",
                Campaign      = safetyKitCampaign,
                StartDateTime = AdjustToTimezone(safetyKitCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(safetyKitCampaign.StartDateTime.AddMonths(1).AddDays(5), _timeZone),
                TimeZoneId    = safetyKitCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            safetyKitHandout.VolunteerTasks = GetSomeVolunteerTasks(safetyKitHandout, organization);
            volunteerTasks.AddRange(safetyKitHandout.VolunteerTasks);
            var carSeatTest1 = new Event
            {
                Name          = "Car Seat Testing-Naperville",
                Description   = "Checking car seats at local fire stations after last day of school year",
                Campaign      = carSafeCampaign,
                StartDateTime = AdjustToTimezone(carSafeCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(carSafeCampaign.StartDateTime.AddMonths(1).AddDays(5), _timeZone),
                TimeZoneId    = carSafeCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            carSeatTest1.VolunteerTasks = GetSomeVolunteerTasks(carSeatTest1, organization);
            volunteerTasks.AddRange(carSeatTest1.VolunteerTasks);
            var carSeatTest2 = new Event
            {
                Name          = "Car Seat and Tire Pressure Checking Volunteer Day",
                Description   = "Checking those things all day at downtown train station parking",
                Campaign      = carSafeCampaign,
                StartDateTime = AdjustToTimezone(carSafeCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(carSafeCampaign.StartDateTime.AddMonths(1).AddDays(5), _timeZone),
                TimeZoneId    = carSafeCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            carSeatTest2.VolunteerTasks = GetSomeVolunteerTasks(carSeatTest2, organization);
            volunteerTasks.AddRange(carSeatTest2.VolunteerTasks);
            var homeFestival = new Event
            {
                Name          = "Park District Home Safety Festival",
                Description   = "At downtown park district(adjacent to pool)",
                Campaign      = safetyKitCampaign,
                StartDateTime = AdjustToTimezone(safetyKitCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(safetyKitCampaign.StartDateTime.AddMonths(1), _timeZone),
                TimeZoneId    = safetyKitCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            homeFestival.VolunteerTasks = GetSomeVolunteerTasks(homeFestival, organization);
            volunteerTasks.AddRange(homeFestival.VolunteerTasks);
            var homeEscape = new Event
            {
                Name          = "Home Escape Plan Flyer Distribution",
                Description   = "Handing out flyers door to door in several areas of town after school/ work hours.Streets / blocks will vary but number of volunteers.",
                Campaign      = escapePlanCampaign,
                StartDateTime = AdjustToTimezone(escapePlanCampaign.StartDateTime.AddDays(1), _timeZone),
                EndDateTime   = AdjustToTimezone(escapePlanCampaign.StartDateTime.AddMonths(7), _timeZone),
                TimeZoneId    = escapePlanCampaign.TimeZoneId,
                Location      = GetRandom(locations),
                EventType     = EventType.Itinerary,
            };
            homeEscape.VolunteerTasks = GetSomeVolunteerTasks(homeEscape, organization);
            volunteerTasks.AddRange(homeEscape.VolunteerTasks);
            #endregion

            #region Link campaign and event

            firePreventionCampaign.Events = new List <Event> {
                queenAnne, ballard, madrona
            };
            smokeDetectorCampaign.Events = new List <Event> {
                southLoopSmoke, northLoopSmoke
            };
            financialCampaign.Events = new List <Event> {
                rentersInsurance, rentersInsuranceEd
            };
            safetyKitCampaign.Events = new List <Event> {
                safetyKitBuild, safetyKitHandout
            };
            carSafeCampaign.Events = new List <Event> {
                carSeatTest1, carSeatTest2
            };
            escapePlanCampaign.Events = new List <Event> {
                homeFestival, homeEscape
            };

            #endregion

            #region Add Campaigns and Events
            organizations.Add(organization);
            campaigns.Add(firePreventionCampaign);
            campaigns.Add(smokeDetectorCampaign);
            campaigns.Add(financialCampaign);
            campaigns.Add(escapePlanCampaign);
            campaigns.Add(safetyKitCampaign);
            campaigns.Add(carSafeCampaign);

            events.AddRange(firePreventionCampaign.Events);
            events.AddRange(smokeDetectorCampaign.Events);
            events.AddRange(financialCampaign.Events);
            events.AddRange(escapePlanCampaign.Events);
            events.AddRange(safetyKitCampaign.Events);
            events.AddRange(carSafeCampaign.Events);
            #endregion

            #region Insert Resource items into Resources
            resources.Add(new Resource
            {
                Name             = "allReady Partner Name",
                Description      = "allready Partner Description",
                PublishDateBegin = DateTime.Today,
                PublishDateEnd   = DateTime.Today.AddDays(14),
                MediaUrl         = "",
                ResourceUrl      = "",
                CategoryTag      = "Partners",
                CampaignId       = 1
            });
            resources.Add(new Resource
            {
                Name             = "allReady Partner Name 2",
                Description      = "allready Partner Description 2",
                PublishDateBegin = DateTime.Today.AddDays(-3),
                PublishDateEnd   = DateTime.Today.AddDays(-1),
                MediaUrl         = "",
                ResourceUrl      = "",
                CategoryTag      = "Partners",
                CampaignId       = 1,
            });
            #endregion

            #region Insert into DB
            _context.Skills.AddRange(skills);
            _context.Contacts.AddRange(contacts);
            _context.EventSkills.AddRange(eventSkills);
            _context.Locations.AddRange(locations);
            _context.Organizations.AddRange(organizations);
            _context.VolunteerTasks.AddRange(volunteerTasks);
            _context.Campaigns.AddRange(campaigns);
            _context.Events.AddRange(events);
            _context.Resources.AddRange(resources);
            //_context.SaveChanges();
            #endregion

            #region Users for Events
            var username1 = $"{_settings.DefaultUsername}1.com";
            var username2 = $"{_settings.DefaultUsername}2.com";
            var username3 = $"{_settings.DefaultUsername}3.com";

            var user1 = new ApplicationUser
            {
                FirstName      = "FirstName1",
                LastName       = "LastName1",
                UserName       = username1,
                Email          = username1,
                EmailConfirmed = true,
                TimeZoneId     = _timeZone.Id,
                PhoneNumber    = "111-111-1111"
            };
            _userManager.CreateAsync(user1, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user1);

            var user2 = new ApplicationUser
            {
                FirstName      = "FirstName2",
                LastName       = "LastName2",
                UserName       = username2,
                Email          = username2,
                EmailConfirmed = true,
                TimeZoneId     = _timeZone.Id,
                PhoneNumber    = "222-222-2222"
            };
            _userManager.CreateAsync(user2, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user2);

            var user3 = new ApplicationUser
            {
                FirstName      = "FirstName3",
                LastName       = "LastName3",
                UserName       = username3,
                Email          = username3,
                EmailConfirmed = true,
                TimeZoneId     = _timeZone.Id,
                PhoneNumber    = "333-333-3333"
            };
            _userManager.CreateAsync(user3, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user3);
            #endregion

            #region Event Managers

            var eventManagerUser = new ApplicationUser
            {
                FirstName      = "Event",
                LastName       = "Manager",
                UserName       = _settings.DefaultEventManagerUsername,
                Email          = _settings.DefaultEventManagerUsername,
                EmailConfirmed = true,
                TimeZoneId     = _timeZone.Id,
                PhoneNumber    = "333-333-3333"
            };
            _userManager.CreateAsync(eventManagerUser, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(eventManagerUser);

            var eventManager = new EventManager
            {
                Event = queenAnne,
                User  = eventManagerUser
            };
            eventManagers.Add(eventManager);

            _context.EventManagers.AddRange(eventManagers);

            #endregion

            #region Campaign Managers

            var campaignManagerUser = new ApplicationUser
            {
                FirstName      = "Campaign",
                LastName       = "Manager",
                UserName       = _settings.DefaultCampaignManagerUsername,
                Email          = _settings.DefaultCampaignManagerUsername,
                EmailConfirmed = true,
                TimeZoneId     = _timeZone.Id,
                PhoneNumber    = "333-333-3333"
            };
            _userManager.CreateAsync(campaignManagerUser, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(campaignManagerUser);

            var campaignManager = new CampaignManager
            {
                Campaign = firePreventionCampaign,
                User     = campaignManagerUser
            };
            campaignManagers.Add(campaignManager);

            _context.CampaignManagers.AddRange(campaignManagers);

            #endregion

            #region TaskSignups
            var i = 0;
            foreach (var volunteerTask in volunteerTasks.Where(t => t.Event == madrona))
            {
                for (var j = 0; j < i; j++)
                {
                    volunteerTaskSignups.Add(new VolunteerTaskSignup {
                        VolunteerTask = volunteerTask, User = users[j], Status = VolunteerTaskStatus.Assigned
                    });
                }

                i = (i + 1) % users.Count;
            }
            _context.VolunteerTaskSignups.AddRange(volunteerTaskSignups);
            #endregion

            #region OrganizationContacts
            organization.OrganizationContacts.Add(new OrganizationContact {
                Contact = contacts.First(), Organization = organization, ContactType = 1                                                             /*Primary*/
            });
            #endregion

            #region Wrap Up DB
            _context.SaveChanges();
            #endregion
        }
Ejemplo n.º 2
0
        //private static ITaskIdProvider _taskIdProvider = new TaskIdProvider();
        public void InsertTestData()
        {
            // Avoid polluting the database if there's already something in there.
            if (_context.Locations.Any() ||
                _context.Organizations.Any() ||
                _context.Tasks.Any() ||
                _context.Campaigns.Any() ||
                _context.Events.Any() ||
                _context.EventSkills.Any() ||
                _context.Skills.Any() ||
                _context.Resources.Any())
            {
                return;
            }

            #region postalCodes
            var existingPostalCode = _context.PostalCodes.ToList();
            _context.PostalCodes.AddRange(GetPostalCodes(existingPostalCode));
            #endregion

            List <Organization>    organizations      = new List <Organization>();
            List <Skill>           organizationSkills = new List <Skill>();
            List <Location>        locations          = GetLocations();
            List <ApplicationUser> users        = new List <ApplicationUser>();
            List <TaskSignup>      taskSignups  = new List <TaskSignup>();
            List <Event>           events       = new List <Event>();
            List <EventSkill>      eventSkills  = new List <EventSkill>();
            List <Campaign>        campaigns    = new List <Campaign>();
            List <AllReadyTask>    tasks        = new List <AllReadyTask>();
            List <Resource>        resources    = new List <Resource>();
            List <EventSignup>     eventSignups = new List <EventSignup>();
            List <Contact>         contacts     = GetContacts();
            var skills = new List <Skill>();

            #region Skills
            var medical = new Skill()
            {
                Name = "Medical", Description = "specific enough, right?"
            };
            var cprCertified = new Skill()
            {
                Name = "CPR Certified", ParentSkill = medical, Description = "ha ha ha ha, stayin alive"
            };
            var md = new Skill()
            {
                Name = "MD", ParentSkill = medical, Description = "Trust me, I'm a doctor"
            };
            var surgeon = new Skill()
            {
                Name = "Surgeon", ParentSkill = md, Description = "cut open; sew shut; play 18 holes"
            };
            skills.AddRange(new[] { medical, cprCertified, md, surgeon });
            #endregion

            #region Organization

            Organization htb = new Organization()
            {
                Name                 = "Humanitarian Toolbox",
                LogoUrl              = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl               = "http://www.htbox.org",
                Location             = locations.FirstOrDefault(),
                Campaigns            = new List <Campaign>(),
                OrganizationContacts = new List <OrganizationContact>(),
            };

            #endregion

            #region Organization Skills

            organizationSkills.Add(new Skill()
            {
                Name               = "Code Ninja",
                Description        = "Ability to commit flawless code without review or testing",
                OwningOrganization = htb
            });

            #endregion

            #region Campaign

            // Campaign 1

            var firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time",
                StartDateTime        = DateTime.UtcNow.AddMonths(-1),
                EndDateTime          = DateTime.UtcNow.AddMonths(3)
            };
            htb.Campaigns.Add(firePrev);

            // Campaign 2

            var smokeDetImpact = new CampaignImpact
            {
                ImpactType         = ImpactType.Numeric,
                NumericImpactGoal  = 10000,
                CurrentImpactLevel = 6722,
                Display            = true,
                TextualImpactGoal  = "Total number of smoke detectors installed."
            };
            _context.CampaignImpacts.Add(smokeDetImpact);

            var smokeDet = new Campaign()
            {
                Name = "Working Smoke Detectors Save Lives",
                ManagingOrganization = htb,
                StartDateTime        = DateTime.Today.AddMonths(-1),
                EndDateTime          = DateTime.Today.AddMonths(1),
                CampaignImpact       = smokeDetImpact,
                TimeZoneId           = "Central Standard Time"
            };
            htb.Campaigns.Add(smokeDet);

            // Campaign 3

            var financial = new Campaign()
            {
                Name = "Everyday Financial Safety",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time",
                StartDateTime        = DateTime.Today.AddMonths(-1),
                EndDateTime          = DateTime.Today.AddMonths(1)
            };
            htb.Campaigns.Add(financial);

            // Campaign 4

            var safetyKit = new Campaign()
            {
                Name = "Simple Safety Kit Building",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time",
                StartDateTime        = DateTime.Today.AddMonths(-1),
                EndDateTime          = DateTime.Today.AddMonths(2)
            };
            htb.Campaigns.Add(safetyKit);

            // Campaign 5

            var carSafe = new Campaign()
            {
                Name = "Family Safety In the Car",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time",
                StartDateTime        = DateTime.Today.AddMonths(-1),
                EndDateTime          = DateTime.Today.AddMonths(2)
            };
            htb.Campaigns.Add(carSafe);

            // Campaign 6

            var escapePlan = new Campaign()
            {
                Name = "Be Ready to Get Out: Have a Home Escape Plan",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time",
                StartDateTime        = DateTime.Today.AddMonths(-6),
                EndDateTime          = DateTime.Today.AddMonths(6)
            };
            htb.Campaigns.Add(escapePlan);

            #endregion

            #region Event
            Event queenAnne = new Event()
            {
                Name           = "Queen Anne Fire Prevention Day",
                StartDateTime  = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime    = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location       = GetRandom <Location>(locations),
                RequiredSkills = new List <EventSkill>()
            };
            queenAnne.Tasks = GetSomeTasks(queenAnne, htb);
            var ask = new EventSkill()
            {
                Skill = surgeon, Event = queenAnne
            };
            queenAnne.RequiredSkills.Add(ask);
            eventSkills.Add(ask);
            ask = new EventSkill()
            {
                Skill = cprCertified, Event = queenAnne
            };
            queenAnne.RequiredSkills.Add(ask);
            eventSkills.Add(ask);
            tasks.AddRange(queenAnne.Tasks);

            Event ballard = new Event()
            {
                Name          = "Ballard Fire Prevention Day",
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 31, 14, 0, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = firePrev
            };
            ballard.Tasks = GetSomeTasks(ballard, htb);
            tasks.AddRange(ballard.Tasks);
            Event madrona = new Event()
            {
                Name          = "Madrona Fire Prevention Day",
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 31, 14, 0, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = firePrev
            };
            madrona.Tasks = GetSomeTasks(madrona, htb);
            tasks.AddRange(madrona.Tasks);
            Event southLoopSmoke = new Event()
            {
                Name          = "Smoke Detector Installation and Testing-South Loop",
                StartDateTime = DateTime.Today.AddMonths(-1),
                EndDateTime   = DateTime.Today.AddMonths(1),
                Location      = GetRandom <Location>(locations),
                Campaign      = smokeDet
            };
            southLoopSmoke.Tasks = GetSomeTasks(southLoopSmoke, htb);
            tasks.AddRange(southLoopSmoke.Tasks);
            Event northLoopSmoke = new Event()
            {
                Name          = "Smoke Detector Installation and Testing-Near North Side",
                StartDateTime = DateTime.Today.AddMonths(-1),
                EndDateTime   = DateTime.Today.AddMonths(1),
                Location      = GetRandom <Location>(locations),
                Campaign      = smokeDet
            };
            northLoopSmoke.Tasks = GetSomeTasks(northLoopSmoke, htb);
            tasks.AddRange(northLoopSmoke.Tasks);
            Event rentersInsurance = new Event()
            {
                Name          = "Renters Insurance Education Door to Door and a bag of chips",
                Description   = "description for the win",
                StartDateTime = new DateTime(2015, 7, 11, 8, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 7, 11, 17, 0, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = financial
            };
            rentersInsurance.Tasks = GetSomeTasks(rentersInsurance, htb);
            tasks.AddRange(rentersInsurance.Tasks);
            Event rentersInsuranceEd = new Event()
            {
                Name          = "Renters Insurance Education Door to Door (woop woop)",
                Description   = "another great description",
                StartDateTime = new DateTime(2015, 7, 12, 8, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 12, 17, 0, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = financial
            };
            rentersInsuranceEd.Tasks = GetSomeTasks(rentersInsuranceEd, htb);
            tasks.AddRange(rentersInsuranceEd.Tasks);
            Event safetyKitBuild = new Event()
            {
                Name          = "Safety Kit Assembly Volunteer Day",
                Description   = "Full day of volunteers building kits",
                StartDateTime = new DateTime(2015, 7, 11, 8, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 11, 16, 30, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = safetyKit
            };
            safetyKitBuild.Tasks = GetSomeTasks(safetyKitBuild, htb);
            tasks.AddRange(safetyKitBuild.Tasks);

            Event safetyKitHandout = new Event()
            {
                Name          = "Safety Kit Distribution Weekend",
                Description   = "Handing out kits at local fire stations",
                StartDateTime = new DateTime(2015, 7, 11, 8, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 11, 16, 30, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = safetyKit
            };
            safetyKitHandout.Tasks = GetSomeTasks(safetyKitHandout, htb);
            tasks.AddRange(safetyKitHandout.Tasks);
            Event carSeatTest1 = new Event()
            {
                Name          = "Car Seat Testing-Naperville",
                Description   = "Checking car seats at local fire stations after last day of school year",
                StartDateTime = new DateTime(2015, 7, 10, 9, 30, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 10, 15, 30, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = carSafe
            };
            carSeatTest1.Tasks = GetSomeTasks(carSeatTest1, htb);
            tasks.AddRange(carSeatTest1.Tasks);
            Event carSeatTest2 = new Event()
            {
                Name          = "Car Seat and Tire Pressure Checking Volunteer Day",
                Description   = "Checking those things all day at downtown train station parking",
                StartDateTime = new DateTime(2015, 7, 11, 8, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 11, 19, 30, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = carSafe
            };
            carSeatTest2.Tasks = GetSomeTasks(carSeatTest2, htb);
            tasks.AddRange(carSeatTest2.Tasks);
            Event homeFestival = new Event()
            {
                Name          = "Park District Home Safety Festival",
                Description   = "At downtown park district(adjacent to pool)",
                StartDateTime = new DateTime(2015, 7, 11, 12, 0, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 11, 16, 30, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = safetyKit
            };
            homeFestival.Tasks = GetSomeTasks(homeFestival, htb);
            tasks.AddRange(homeFestival.Tasks);
            Event homeEscape = new Event()
            {
                Name          = "Home Escape Plan Flyer Distribution",
                Description   = "Handing out flyers door to door in several areas of town after school/ work hours.Streets / blocks will vary but number of volunteers.",
                StartDateTime = new DateTime(2015, 7, 15, 15, 30, 0).ToUniversalTime(),
                EndDateTime   = new DateTime(2015, 12, 15, 20, 30, 0).ToUniversalTime(),
                Location      = GetRandom <Location>(locations),
                Campaign      = escapePlan
            };
            homeEscape.Tasks = GetSomeTasks(homeEscape, htb);
            tasks.AddRange(homeEscape.Tasks);
            #endregion
            #region Link campaign and event
            firePrev.Events = new List <Event>();
            firePrev.Events.Add(queenAnne);
            firePrev.Events.Add(ballard);
            firePrev.Events.Add(madrona);
            smokeDet.Events = new List <Event>();
            smokeDet.Events.Add(southLoopSmoke);
            smokeDet.Events.Add(northLoopSmoke);
            financial.Events = new List <Event>();
            financial.Events.Add(rentersInsurance);
            financial.Events.Add(rentersInsuranceEd);
            safetyKit.Events = new List <Event>();
            safetyKit.Events.Add(safetyKitBuild);
            safetyKit.Events.Add(safetyKitHandout);
            carSafe.Events = new List <Event>();
            carSafe.Events.Add(carSeatTest1);
            carSafe.Events.Add(carSeatTest2);
            escapePlan.Events = new List <Event>();
            escapePlan.Events.Add(homeFestival);
            escapePlan.Events.Add(homeEscape);
            #endregion
            #region Add Campaigns and Events
            organizations.Add(htb);
            campaigns.Add(firePrev);
            campaigns.Add(smokeDet);
            campaigns.Add(financial);
            campaigns.Add(escapePlan);
            campaigns.Add(safetyKit);
            campaigns.Add(carSafe);

            events.AddRange(firePrev.Events);
            events.AddRange(smokeDet.Events);
            events.AddRange(financial.Events);
            events.AddRange(escapePlan.Events);
            events.AddRange(safetyKit.Events);
            events.AddRange(carSafe.Events);
            #endregion

            #region Insert Resource items into Resources
            resources.Add(new Resource
            {
                Name             = "allReady Partner Name",
                Description      = "allready Partner Description",
                PublishDateBegin = DateTime.Today,
                PublishDateEnd   = DateTime.Today.AddDays(14),
                MediaUrl         = "",
                ResourceUrl      = "",
                CategoryTag      = "Partners"
            });
            resources.Add(new Resource
            {
                Name             = "allReady Partner Name 2",
                Description      = "allready Partner Description 2",
                PublishDateBegin = DateTime.Today.AddDays(-3),
                PublishDateEnd   = DateTime.Today.AddDays(-1),
                MediaUrl         = "",
                ResourceUrl      = "",
                CategoryTag      = "Partners"
            });
            #endregion

            #region Insert into DB
            _context.Skills.AddRange(skills);
            _context.Contacts.AddRange(contacts);
            _context.EventSkills.AddRange(eventSkills);
            _context.Locations.AddRange(locations);
            _context.Organizations.AddRange(organizations);
            _context.Tasks.AddRange(tasks);
            _context.Campaigns.AddRange(campaigns);
            _context.Events.AddRange(events);
            _context.Resources.AddRange(resources);
            //_context.SaveChanges();
            #endregion

            #region Users for Events
            var username1 = $"{_settings.DefaultUsername}1.com";
            var username2 = $"{_settings.DefaultUsername}2.com";
            var username3 = $"{_settings.DefaultUsername}3.com";

            var user1 = new ApplicationUser {
                UserName = username1, Email = username1, EmailConfirmed = true, TimeZoneId = _generalSettings.DefaultTimeZone, PhoneNumber = "111-111-1111"
            };
            _userManager.CreateAsync(user1, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user1);

            var user2 = new ApplicationUser {
                UserName = username2, Email = username2, EmailConfirmed = true, TimeZoneId = _generalSettings.DefaultTimeZone, PhoneNumber = "222-222-2222"
            };
            _userManager.CreateAsync(user2, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user2);

            var user3 = new ApplicationUser {
                UserName = username3, Email = username3, EmailConfirmed = true, TimeZoneId = _generalSettings.DefaultTimeZone, PhoneNumber = "333-333-3333"
            };
            _userManager.CreateAsync(user3, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user3);
            #endregion

            #region ActvitySignups
            eventSignups.Add(new EventSignup {
                Event = madrona, User = user1, SignupDateTime = DateTime.UtcNow
            });
            eventSignups.Add(new EventSignup {
                Event = madrona, User = user2, SignupDateTime = DateTime.UtcNow
            });
            eventSignups.Add(new EventSignup {
                Event = madrona, User = user3, SignupDateTime = DateTime.UtcNow
            });
            #endregion

            #region TaskSignups
            int i = 0;
            foreach (var task in tasks.Where(t => t.Event == madrona))
            {
                for (var j = 0; j < i; j++)
                {
                    taskSignups.Add(new TaskSignup()
                    {
                        Task = task, User = users[j], Status = Areas.Admin.Features.Tasks.TaskStatus.Assigned.ToString()
                    });
                }

                i = (i + 1) % users.Count;
            }
            _context.TaskSignups.AddRange(taskSignups);
            #endregion

            #region TennatContacts
            htb.OrganizationContacts.Add(new OrganizationContact {
                Contact = contacts.First(), Organization = htb, ContactType = 1                                                    /*Primary*/
            });
            #endregion

            #region Wrap Up DB
            _context.EventSignup.AddRange(eventSignups);
            _context.SaveChanges();
            #endregion
        }