Пример #1
0
 protected override void LoadTestData()
 {
     var context = ServiceProvider.GetService<AllReadyContext>();
     Organization htb = new Organization()
     {
         Id = 1,
         Name = "Humanitarian Toolbox",
         LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
         WebUrl = "http://www.htbox.org",
         Campaigns = new List<Campaign>(),                
     };
     Organization other = new Organization()
     {
         Id = 2,
         Name = "Other Org",
         Campaigns = new List<Campaign>(),
     };
     Campaign firePrev = new Campaign()
     {
         Id = 1,
         Name = "Neighborhood Fire Prevention Days",
         ManagingOrganization = htb
     };
     Campaign otherCampaign = new Campaign()
     {
         Id = 2,
         Name = "Some other campaign",
         ManagingOrganization = other
     };
     htb.Campaigns.Add(firePrev);
     context.Organizations.Add(htb);
     other.Campaigns.Add(otherCampaign);
     context.Organizations.Add(other);
     context.SaveChanges();
 }
        protected override void LoadTestData()
        {
            var org = new Organization
            {
                Name = "Some Organization"
            };

            Context.Organizations.Add(org);

            Context.Campaigns.Add(new Campaign
            {
                Name = "This is featured",
                Featured = true,
                ManagingOrganization = org                
            });

            Context.Campaigns.Add(new Campaign
            {
                Name = "This is not featured",
                Featured = false,
                ManagingOrganization = org
            });

            Context.Campaigns.Add(new Campaign
            {
                Name = "This is also featured",
                Featured = true,
                ManagingOrganization = org
            });

            Context.SaveChanges();
        }
Пример #3
0
        public void ActivityDoesNotExist()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            Organization htb = new Organization()
            {
                Id = 123,
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };
            Campaign firePrev = new Campaign()
            {
                Id = 1,
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb,
                TimeZoneId = "Central Standard Time"
            };
            htb.Campaigns.Add(firePrev);
            context.Organizations.Add(htb);
            context.SaveChanges();

            var vm = new ActivityDetailModel
            {
                CampaignId = 1,
                TimeZoneId = "Central Standard Time"
            };
            var query = new EditActivityCommand { Activity = vm };
            var handler = new EditActivityCommandHandler(context);
            var result = handler.Handle(query);
            Assert.True(result > 0);

            var data = context.Activities.Count(_ => _.Id == result);
            Assert.True(data == 1);
        }
Пример #4
0
 protected override void LoadTestData()
 {
     var context = ServiceProvider.GetService<AllReadyContext>();
     Organization htb = new Organization()
     {
         Name = "Humanitarian Toolbox",
         LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
         WebUrl = "http://www.htbox.org",
         Campaigns = new List<Campaign>()
     };
     Campaign firePrev = new Campaign()
     {
         Name = "Neighborhood Fire Prevention Days",
         ManagingOrganization = htb
     };
     htb.Campaigns.Add(firePrev);
     Activity queenAnne = new Activity()
     {
         Id = 1,
         Name = "Queen Anne Fire Prevention Day",
         Campaign = firePrev,
         CampaignId = firePrev.Id,
         StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
         EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
         Location = new Location { Id = 1 },
         RequiredSkills = new List<ActivitySkill>()
     };
     context.Organizations.Add(htb);
     context.Activities.Add(queenAnne);
     context.SaveChanges();
 }
Пример #5
0
        public void ExistingCampaign()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            Organization htb = new Organization()
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };
            Campaign firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb,
                TimeZoneId = "Eastern Standard Time"
            };
            htb.Campaigns.Add(firePrev);
            context.Organizations.Add(htb);
            context.SaveChanges();

            const string NEW_NAME = "Some new name value";

            var startDate = new DateTime(2014, 12, 10);
            var endDate = new DateTime(2015, 7, 3);
            var vm = new CampaignSummaryModel
            {
                Description = firePrev.Description,
                EndDate = endDate,
                FullDescription = firePrev.FullDescription,
                StartDate = startDate,
                Id = firePrev.Id,
                ImageUrl = firePrev.ImageUrl,
                Name = NEW_NAME,
                OrganizationId = firePrev.ManagingOrganizationId,
                OrganizationName = firePrev.ManagingOrganization.Name,
                TimeZoneId = "Eastern Standard Time"
            };
            var query = new EditCampaignCommand { Campaign = vm };
            var handler = new EditCampaignCommandHandler(context);
            var result = handler.Handle(query);
            Assert.Equal(1, result); // should get back the Campaign id

            var data = context.Campaigns.Single(_ => _.Id == 1);
            Assert.Equal(NEW_NAME, data.Name);

            Assert.Equal(2014, data.StartDateTime.Year);
            Assert.Equal(12, data.StartDateTime.Month);
            Assert.Equal(10, data.StartDateTime.Day);
            Assert.Equal(00, data.StartDateTime.Hour);
            Assert.Equal(00, data.StartDateTime.Minute);
            Assert.Equal(-5, data.StartDateTime.Offset.TotalHours);

            Assert.Equal(2015, data.EndDateTime.Year);
            Assert.Equal(7, data.EndDateTime.Month);
            Assert.Equal(3, data.EndDateTime.Day);
            Assert.Equal(23, data.EndDateTime.Hour);
            Assert.Equal(59, data.EndDateTime.Minute);
            Assert.Equal(-4, data.EndDateTime.Offset.TotalHours);
            
        }
Пример #6
0
        protected override void LoadTestData()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            Organization htb = new Organization()
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };
            Campaign firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            Activity queenAnne = new Activity()
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<ActivitySkill>(),
            };

            var username1 = $"*****@*****.**";
            var username2 = $"*****@*****.**";

            var user1 = new ApplicationUser { UserName = username1, Email = username1, EmailConfirmed = true };
            context.Users.Add(user1);

            htb.Campaigns.Add(firePrev);
            context.Organizations.Add(htb);
            context.Activities.Add(queenAnne);

            var activitySignups = new List<ActivitySignup>();
            activitySignups.Add(new ActivitySignup { Activity = queenAnne, User = user1, SignupDateTime = DateTime.UtcNow });

            context.ActivitySignup.AddRange(activitySignups);

            var newTask = new AllReadyTask()
            {
                Activity = queenAnne,
                Description = "Description of a very important task",
                Name = "Task # 1",
                EndDateTime = DateTime.Now.AddDays(5),
                StartDateTime = DateTime.Now.AddDays(3),
                Organization = htb
            };
            newTask.AssignedVolunteers.Add(new TaskSignup()
            {
                Task = newTask,
                User = user1
            });
            context.Tasks.Add(newTask);

            context.SaveChanges();
        }
Пример #7
0
        protected override void LoadTestData()
        {
            _htb = new Organization()
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            _firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = _htb,
                CampaignContacts = new List<CampaignContact>()
            };
            
            _htb.Campaigns.Add(_firePrev);
            _queenAnne = new Event()
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = _firePrev,
                CampaignId = _firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
                Tasks = new List<AllReadyTask>()
            };
            Context.Events.Add(_queenAnne);
            Context.SaveChanges();
        }
        protected override void LoadTestData()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            var htb = new Organization
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };

            var queenAnne = new Event
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
            };

            var username1 = $"*****@*****.**";
            var username2 = $"*****@*****.**";

            var user1 = new ApplicationUser { UserName = username1, Email = username1, EmailConfirmed = true };
            context.Users.Add(user1);
            var user2 = new ApplicationUser { UserName = username2, Email = username2, EmailConfirmed = true };
            context.Users.Add(user2);

            htb.Campaigns.Add(firePrev);            
            context.Organizations.Add(htb);
            
            var task = new AllReadyTask
            {
                Event = queenAnne,
                Description = "Description of a very important task",
                Name = "Task # ",
                EndDateTime = DateTime.Now.AddDays(1),
                StartDateTime = DateTime.Now.AddDays(-3)
            };
            queenAnne.Tasks.Add(task);
            context.Events.Add(queenAnne);

            var taskSignups = new List<TaskSignup>
            {
                new TaskSignup { Task = task, User = user1 },
                new TaskSignup { Task = task, User = user2 }
            };
            context.TaskSignups.AddRange(taskSignups);

            context.SaveChanges();
        }
        public async Task ReturnNullIfFeaturedCampaignIsNotMarkedAsPublished()
        {
            // clear the test data of all campaigns
            var allCampaigns = Context.Campaigns.ToList();
            Context.RemoveRange(allCampaigns);
            Context.SaveChanges();

            var org = new Organization
            {
                Name = "Some Organization"
            };

            Context.Campaigns.Add(new Campaign
            {
                Name = "This is featured but not published",
                Featured = true,
                ManagingOrganization = org,
                Published = false
            });



            // Arrange
            var handler = new FeaturedCampaignQueryHandler(Context);

            // Act
            var result = await handler.Handle(new FeaturedCampaignQuery());

            // Assert
            Assert.Null(result);
        }
        protected override void LoadTestData()
        {
            var htb = new Organization()
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };

            var queenAnne = new Event()
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
            };

            var username1 = $"*****@*****.**";
            var username2 = $"*****@*****.**";

            var user1 = new ApplicationUser { UserName = username1, Email = username1, EmailConfirmed = true };
            Context.Users.Add(user1);
            var user2 = new ApplicationUser { UserName = username2, Email = username2, EmailConfirmed = true };
            Context.Users.Add(user2);

            var task = new AllReadyTask
            {
                Id = 1,
                Name = "Task 1",
                Event = queenAnne,
            };

            var taskSignup = new TaskSignup
            {
                Id = 1,
                User = user1,
                Task = task
            };

            htb.Campaigns.Add(firePrev);            
            Context.Organizations.Add(htb);
            Context.Events.Add(queenAnne);
            Context.Tasks.Add(task);
            Context.TaskSignups.Add(taskSignup);

            Context.SaveChanges();
        }
        public async Task UpdateExistingTaskSuccessfully()
        {
            var @event = new Event { Id = 3 };
            var organization = new Organization { Id = 4 };
            var task = new AllReadyTask
            {
                Id = 2,
                Name = "TaskName",
                Description = "TaskDescription",
                Event = @event,
                Organization = organization,
                StartDateTime = DateTimeOffset.Now,
                EndDateTime = DateTimeOffset.Now,
                NumberOfVolunteersRequired = 5,
                RequiredSkills = new List<TaskSkill> { new TaskSkill { SkillId = 5, Skill = new Skill { Id = 5, Name = "SkillName", Description = "SkillDescription" } } }
            };

            Context.Database.EnsureDeleted();
            Context.Events.Add(@event);
            Context.Organizations.Add(organization);
            Context.Tasks.Add(task);
            Context.SaveChanges();

            var message = new EditTaskCommandAsync
            {
                Task = new EditViewModel
                {
                    Id = task.Id,
                    Name = "TaskNameUpdated",
                    Description = "TaskDescriptionUpdated",
                    EventId = @event.Id,
                    OrganizationId = organization.Id,
                    TimeZoneId = "Central Standard Time",
                    StartDateTime = DateTimeOffset.Now.AddDays(1),
                    EndDateTime = DateTimeOffset.Now.AddDays(2),
                    NumberOfVolunteersRequired = 6,
                    RequiredSkills = new List<TaskSkill> { new TaskSkill { SkillId = 6, Skill = new Skill { Id = 6, Name = "SkillNameOnMessage", Description = "SkillDescriptionOnMessage" } } }
                }
            };

            var sut = new EditTaskCommandHandlerAsync(Context);
            var taskId = await sut.Handle(message);
            var result = Context.Tasks.Single(x => x.Id == taskId);

            //can't test start and end date as they're tied to static classes
            Assert.Equal(taskId, message.Task.Id);
            Assert.Equal(result.Name, message.Task.Name);
            Assert.Equal(result.Description, message.Task.Description);
            Assert.Equal(result.Event, @event);
            Assert.Equal(result.Organization, organization);
            Assert.Equal(result.NumberOfVolunteersRequired, message.Task.NumberOfVolunteersRequired);
            Assert.Equal(result.IsLimitVolunteers, @event.IsLimitVolunteers);
            Assert.Equal(result.IsAllowWaitList, @event.IsAllowWaitList);
            Assert.Equal(result.RequiredSkills, message.Task.RequiredSkills);
        }
        Task IAllReadyDataAccess.UpdateOrganization(Organization value)
        {
            var organization = _dbContext.Organizations.SingleOrDefault(c => c.Id == value.Id);

            if (organization != null)
            {
                _dbContext.Organizations.Update(organization);
                return _dbContext.SaveChangesAsync();
            }
            return null;
        }
        public async Task ReturnOrganziationNameWhenThereIsAMatchingOrganizationId()
        {
            var organization = new Organization { Id = 1, Name = "OrganizationName" };
            var context = Context;
            context.Organizations.Add(organization);
            context.SaveChanges();

            var sut = new OrganizationNameQueryHandler(context);
            var result = await sut.Handle(new OrganizationNameQuery { Id = organization.Id });

            Assert.Equal(result, organization.Name);
        }
        protected override void LoadTestData()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();

            var seattlePostalCode = new PostalCodeGeo { City = "Seattle", PostalCode = "98117", State = "WA" };
            var seattle = new Location
            {
                Id = 1,
                Address1 = "123 Main Street",
                Address2 = "Unit 2",
                City = "Seattle",
                PostalCode = seattlePostalCode,
                Country = "USA",
                State = "WA",
                Name = "Organizer name",
                PhoneNumber = "555-555-5555"                            
            };
         

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

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);

            var queenAnne = new Event
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>()
            };

            context.PostalCodes.Add(seattlePostalCode);
            context.Locations.Add(seattle);
            context.Organizations.Add(htb);
            context.Events.Add(queenAnne);
            context.SaveChanges();
        }
Пример #15
0
        protected override void LoadTestData()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            var htb = new Organization()
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };

            var queenAnne = new Activity()
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<ActivitySkill>(),
            };

            var username1 = $"*****@*****.**";
            var username2 = $"*****@*****.**";

            var user1 = new ApplicationUser { UserName = username1, Email = username1, EmailConfirmed = true };
            context.Users.Add(user1);
            var user2 = new ApplicationUser { UserName = username2, Email = username2, EmailConfirmed = true };
            context.Users.Add(user2);

            htb.Campaigns.Add(firePrev);            
            context.Organizations.Add(htb);
            context.Activities.Add(queenAnne);

            var activitySignups = new List<ActivitySignup>
            {
                new ActivitySignup { Activity = queenAnne, User = user1, SignupDateTime = DateTime.UtcNow },
                new ActivitySignup { Activity = queenAnne, User = user2, SignupDateTime = DateTime.UtcNow }
            };

            context.ActivitySignup.AddRange(activitySignups);
            context.SaveChanges();
        }
        protected override void LoadTestData()
        {
            var htb = new Organization
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);

            var queenAnne = new Event
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>(),
                EventType = EventType.Itinerary
            };

            var itinerary = new Itinerary
            {
                Event = queenAnne,
                Name = "1st Itinerary",
                Id = 1,
                Date = new DateTime(2016, 07, 01)
            };

            var taskSignUp = new TaskSignup { Id = 1, ItineraryId = 2, TaskId = 1 };

            Context.Organizations.Add(htb);
            Context.Campaigns.Add(firePrev);
            Context.Events.Add(queenAnne);
            Context.Itineraries.Add(itinerary);
            Context.TaskSignups.Add(taskSignUp);

            Context.SaveChanges();
        }
Пример #17
0
        public OrganizationViewModel(Organization organization)
        {
            Id = organization.Id;
            Name = organization.Name;
            LogoUrl = organization.LogoUrl;
            WebUrl = organization.WebUrl;

            if (organization.Campaigns != null)
            {
                Campaigns = organization.Campaigns.ToViewModel().ToList();
            }
            else
            {
                Campaigns = new List<CampaignViewModel>();
            }
        }
        protected override void LoadTestData()
        {
            var organization = new Organization
            {
                Id = 1,
                Name = "Org 1",
                WebUrl = "http://www.org1.org",
                LogoUrl = "http://www.org1Logo.org",
                Location = new Location { Id = 1, Country="USA" },
                Campaigns = new List<Campaign>(),
                Users = new List<ApplicationUser>(),
                OrganizationContacts = new List<OrganizationContact>()
            };
            var campaign = new Campaign
            {
                Id = 1,
                Name = "Campaign 1",
                ManagingOrganizationId = 1
            };
            var user = new ApplicationUser
            {
                Id = Guid.NewGuid().ToString(),
                Email = "*****@*****.**"

            };
            var organizationContact = new OrganizationContact
            {
                OrganizationId = 1,
                ContactType = (int)ContactTypes.Primary,
                Contact = new Contact
                {
                    Id = 1,
                    Email = "*****@*****.**",
                    FirstName = "firstName",
                    LastName = "lastName",
                    PhoneNumber = "123"
                }
            };

            Context.Organizations.Add(organization);
            Context.Campaigns.Add(campaign);
            Context.Users.Add(user);
            Context.OrganizationContacts.Add(organizationContact);
            Context.SaveChanges();
        }
Пример #19
0
        public OrganizationViewModel(Organization organization)
        {
            Id = organization.Id;
            Name = organization.Name;
            LogoUrl = organization.LogoUrl;
            WebUrl = organization.WebUrl;

            if (organization.Campaigns != null)
            {
                Campaigns = organization.Campaigns.ToViewModel().ToList();
            }
            else
            {
                Campaigns = new List<CampaignViewModel>();
            }

            HasPrivacyPolicy = !string.IsNullOrEmpty(organization.PrivacyPolicy);
        }
        /// <summary>
        /// Creates an OrganizationEditModel from an existing Organization 
        /// </summary>
        /// <param name="organization">An Organization that will be supply the initial values for editing.</param>
        /// <returns>An OrganizationEditModel that can be used to capture the fields for an Organization
        /// and it's location and primary contact built from values from the supplied organization. </returns>
        public static OrganizationEditModel ToEditModel_Organization(Organization organization)
        {
            OrganizationEditModel ret = new OrganizationEditModel()
            {
                Id = organization.Id,
                Name = organization.Name,
                Location = organization.Location.ToEditModel(),
                LogoUrl = organization.LogoUrl,
                WebUrl = organization.WebUrl,
                PrivacyPolicy = organization.PrivacyPolicy
            };
            if (organization.OrganizationContacts?.SingleOrDefault(tc => tc.ContactType == (int)ContactTypes.Primary)?.Contact != null)
            {
                ret = (OrganizationEditModel)organization.OrganizationContacts?.SingleOrDefault(tc => tc.ContactType == (int)ContactTypes.Primary)?.Contact.ToEditModel(ret);
            }

            return ret;
        }
        protected override void LoadTestData()
        {
            var htb = new Organization
            {
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Campaigns = new List<Campaign>()
            };

            var firePrev = new Campaign
            {
                Id = 1,
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);
            Context.Organizations.Add(htb);
            Context.SaveChanges();
        }
Пример #22
0
        protected override void LoadTestData()
        {
            rnd = new Random();
            context = ServiceProvider.GetService<AllReadyContext>();
            var tasks = context.Tasks.ToList();
            _task = GenerateTask();

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

            var firePrev = new Campaign
            {
                Name = "test Campaign",
                ManagingOrganization = htb
            };

            var myEvent = new Event
            {
                Id = rnd.Next(3,1000),
                Campaign = firePrev,
                CampaignId = firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<EventSkill>()
            };

            _task.Event = myEvent;
            context.Organizations.Add(htb);

            context.Campaigns.Add(firePrev);
            context.Events.Add(myEvent);
            context.Tasks.Add(_task);
            tasks = context.Tasks.ToList();
            context.SaveChanges();
        }
        public async Task CreateNewTaskSuccessfully()
        {
            var @event = new Event { Id = 1, IsLimitVolunteers = true, IsAllowWaitList = false };
            var organization = new Organization { Id = 2 };

            var message = new EditTaskCommandAsync
            {
                Task = new EditViewModel
                {
                    Name = "TaskName",
                    Description = "TaskDescription",
                    EventId = @event.Id,
                    OrganizationId = organization.Id,
                    TimeZoneId = "Central Standard Time",
                    StartDateTime = DateTimeOffset.Now,
                    EndDateTime = DateTimeOffset.Now,
                    NumberOfVolunteersRequired = 5,
                    RequiredSkills = new List<TaskSkill> { new TaskSkill { SkillId = 3, Skill = new Skill { Id = 3, Name = "SkillName", Description = "SkillDescription" } } }
                }
            };

            Context.Database.EnsureDeleted();
            Context.Events.Add(@event);
            Context.Organizations.Add(organization);
            Context.SaveChanges();

            var sut = new EditTaskCommandHandlerAsync(Context);
            var taskId = await sut.Handle(message);
            var result = Context.Tasks.Single(x => x.Id == taskId);

            Assert.True(taskId > 0);
            Assert.Equal(result.Name, message.Task.Name);
            Assert.Equal(result.Description, message.Task.Description);
            Assert.Equal(result.Event, @event);
            Assert.Equal(result.Organization, organization);
            Assert.Equal(result.NumberOfVolunteersRequired, message.Task.NumberOfVolunteersRequired);
            Assert.Equal(result.IsLimitVolunteers, @event.IsLimitVolunteers);
            Assert.Equal(result.IsAllowWaitList, @event.IsAllowWaitList);
            Assert.Equal(result.RequiredSkills, message.Task.RequiredSkills);
        }
        public async Task EventDoesNotExist()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();

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

            var firePrev = new Campaign
            {
                Id = 1,
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb,
                TimeZoneId = "Central Standard Time"
            };
            htb.Campaigns.Add(firePrev);

            context.Organizations.Add(htb);
            context.SaveChanges();

            var vm = new EventEditViewModel
            {
                CampaignId = 1,
                TimeZoneId = "Central Standard Time"
            };

            var query = new EditEventCommand { Event = vm };
            var handler = new EditEventCommandHandler(context, Mock.Of<IConvertDateTimeOffset>());
            var result = await handler.Handle(query);
            Assert.True(result > 0);

            var data = context.Events.Count(_ => _.Id == result);
            Assert.True(data == 1);
        }
    protected override void LoadTestData()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();

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

            var firePrev = new Campaign
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb
            };
            htb.Campaigns.Add(firePrev);
            context.Organizations.Add(htb);
            context.SaveChanges();

            _campaignId = firePrev.Id;
        }
        protected override void LoadTestData()
        {
            var htb = new Organization
            {
                Id = 1,
                Name = "Humanitarian Toolbox",
                LogoUrl = "http://www.htbox.org/upload/home/ht-hero.png",
                WebUrl = "http://www.htbox.org",
                Location = new Location { Id = 1},
                OrganizationContacts = new List<OrganizationContact>
                {
                    new OrganizationContact
                    {
                        ContactType = (int) ContactTypes.Primary,
                        Contact = new Contact {FirstName = "Regina"}
                    }
                },
                Campaigns = new List<Campaign>()
            };

            Context.Organizations.Add(htb);
            Context.SaveChanges();
        }
Пример #27
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 firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time"
            };
            htb.Campaigns.Add(firePrev);
            var smokeDetImpact = new CampaignImpact
            {
                ImpactType         = ImpactType.Numeric,
                NumericImpactGoal  = 10000,
                CurrentImpactLevel = 6722,
                Display            = true,
                TextualImpactGoal  = "Total number of smoke detectors installed."
            };
            _context.CampaignImpacts.Add(smokeDetImpact);
            Campaign 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 financial = new Campaign()
            {
                Name = "Everyday Financial Safety",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time"
            };
            htb.Campaigns.Add(financial);
            Campaign safetyKit = new Campaign()
            {
                Name = "Simple Safety Kit Building",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time"
            };
            htb.Campaigns.Add(safetyKit);
            Campaign carSafe = new Campaign()
            {
                Name = "Family Safety In the Car",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time"
            };
            htb.Campaigns.Add(carSafe);
            Campaign escapePlan = new Campaign()
            {
                Name = "Be Ready to Get Out: Have a Home Escape Plan",
                ManagingOrganization = htb,
                TimeZoneId           = "Central Standard Time"
            };
            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
            };
            _userManager.CreateAsync(user1, _settings.DefaultAdminPassword).GetAwaiter().GetResult();
            users.Add(user1);

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

            var user3 = new ApplicationUser {
                UserName = username3, Email = username3, EmailConfirmed = true, TimeZoneId = _generalSettings.DefaultTimeZone
            };
            _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
        }
        protected override void LoadTestData()
        {
            var context = ServiceProvider.GetService<AllReadyContext>();
            _user1 = new ApplicationUser
            {
                UserName = "******",
                Name = "John Doe",
                Email = "*****@*****.**"
            };
            _contact1 = new Contact
            {
                Id = 1,
                FirstName = "Jerry",
                LastName = "Rodgers",
                Email = "*****@*****.**",
                PhoneNumber = "555.555.1234"
            };

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

            _firePrev = new Campaign()
            {
                Name = "Neighborhood Fire Prevention Days",
                ManagingOrganization = _htb,
                CampaignContacts = new List<CampaignContact>()
            };
            _firePrev.CampaignContacts.Add(new CampaignContact
            {
                Campaign = _firePrev,
                Contact = _contact1,
                ContactType = (int)ContactTypes.Primary
            });
            _htb.Campaigns.Add(_firePrev);
            _queenAnne = new Activity()
            {
                Id = 1,
                Name = "Queen Anne Fire Prevention Day",
                Campaign = _firePrev,
                CampaignId = _firePrev.Id,
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Location = new Location { Id = 1 },
                RequiredSkills = new List<ActivitySkill>(),
                Tasks = new List<AllReadyTask>()
            };
            _queenAnne.UsersSignedUp = new List<ActivitySignup>
            {
                new ActivitySignup
                {
                    Id = 1,
                    PreferredEmail = "*****@*****.**",
                    PreferredPhoneNumber = "(555)555-1234",
                    User = _user1
                }
            };
            _task1 = new AllReadyTask()
            {
               Id = 1,
               Activity = _queenAnne,
               Name = "Task 1",
                StartDateTime = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
                EndDateTime = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
                Organization = _htb
            };
            _task1.AssignedVolunteers = new List<TaskSignup>()
            {
                new TaskSignup
                {
                    Id = 1,
                    User = _user1,
                    Task = _task1,
                    Status = "Assigned",
                    StatusDateTimeUtc = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime()
                }
            };
            _queenAnne.Tasks.Add(_task1);
            context.Users.Add(_user1);
            context.Contacts.Add(_contact1);
            context.Organizations.Add(_htb);
            context.Activities.Add(_queenAnne);
            context.SaveChanges();
        }
 public void SetManagingOrganizationLogoToCampaignsOrganizationsName_WhenCampaignsManagingOrganizationIsNotNull_AndLogoUrlIsNotAnEmptyString()
 {
     var organization = new Organization { LogoUrl = "logoUrl" };
     var sut = new CampaignViewModel(new Models.Campaign { ManagingOrganization = organization });
     Assert.Equal(sut.ManagingOrganizationLogo, organization.LogoUrl);
 }
 public void SetManagingOrganizationIdToCampaignsManagingOrganizationId_WhenCampaignsManagingOrganizationIsNotNull_AndIdIsNotZero()
 {
     var organization = new Organization { Id = 1 };
     var sut = new CampaignViewModel(new Models.Campaign { ManagingOrganization = organization });
     Assert.Equal(sut.ManagingOrganizationId, organization.Id);
 }
 public void SetManagingOrganizationNameToCampaignsOrganizationsName_WhenCampaignsManagingOrganizationIsNotNull_AndNameIsNotAnEmptyString()
 {
     var organization = new Organization { Name = "organizationNamee" };
     var sut = new CampaignViewModel(new Models.Campaign { ManagingOrganization = organization });
     Assert.Equal(sut.ManagingOrganizationName, organization.Name);
 }
 Task IAllReadyDataAccess.AddOrganization(Organization value)
 {
     _dbContext.Organizations.Add(value);
     return(_dbContext.SaveChangesAsync());
 }