本文整理汇总了C#中AllReady.Models.Campaign类的典型用法代码示例。如果您正苦于以下问题:C# Campaign类的具体用法?C# Campaign怎么用?C# Campaign使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Campaign类属于AllReady.Models命名空间,在下文中一共展示了Campaign类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActivityDoesNotExist
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);
}
示例2: LoadTestData
protected override void LoadTestData()
{
var context = ServiceProvider.GetService<AllReadyContext>();
Tenant htb = new Tenant()
{
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",
ManagingTenant = htb
};
Activity queenAnne = new Activity()
{
Id = 1,
Name = "Queen Anne Fire Prevention Day",
Campaign = firePrev,
CampaignId = firePrev.Id,
StartDateTimeUtc = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
EndDateTimeUtc = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
Location = new Location { Id = 1 },
RequiredSkills = new List<ActivitySkill>(),
};
var username1 = $"[email protected]";
var username2 = $"[email protected]";
var user1 = new ApplicationUser { UserName = username1, Email = username1, EmailConfirmed = true };
context.Users.Add(user1);
htb.Campaigns.Add(firePrev);
context.Tenants.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",
EndDateTimeUtc = DateTime.Now.AddDays(5),
StartDateTimeUtc = DateTime.Now.AddDays(3),
Tenant = htb
};
newTask.AssignedVolunteers.Add(new TaskSignup()
{
Task = newTask,
User = user1
});
context.Tasks.Add(newTask);
context.SaveChanges();
}
示例3: ExistingActivity
public void ExistingActivity()
{
var context = ServiceProvider.GetService<AllReadyContext>();
Tenant htb = new Tenant()
{
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",
ManagingTenant = htb
};
htb.Campaigns.Add(firePrev);
Activity queenAnne = new Activity()
{
Id = 100,
Name = "Queen Anne Fire Prevention Day",
Campaign = firePrev,
CampaignId = firePrev.Id,
StartDateTimeUtc = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
EndDateTimeUtc = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
Location = new Location { Id = 1 },
RequiredSkills = new List<ActivitySkill>()
};
context.Tenants.Add(htb);
context.Activities.Add(queenAnne);
context.SaveChanges();
const string NEW_NAME = "Some new name value";
var vm = new ActivityDetailModel
{
CampaignId = queenAnne.CampaignId,
CampaignName = queenAnne.Campaign.Name,
Description = queenAnne.Description,
EndDateTime = queenAnne.EndDateTimeUtc,
Id = queenAnne.Id,
ImageUrl = queenAnne.ImageUrl,
Location = null,
Name = NEW_NAME,
RequiredSkills = queenAnne.RequiredSkills,
StartDateTime = queenAnne.StartDateTimeUtc,
Tasks = null,
TenantId = queenAnne.Campaign.ManagingTenantId,
TenantName = queenAnne.Campaign.ManagingTenant.Name,
Volunteers = null
};
var query = new EditActivityCommand { Activity = vm };
var handler = new EditActivityCommandHandler(context);
var result = handler.Handle(query);
Assert.Equal(100, result); // should get back the activity id
var data = context.Activities.Single(_ => _.Id == result);
Assert.Equal(NEW_NAME, data.Name);
}
示例4: LoadTestData
protected override void LoadTestData()
{
var context = ServiceProvider.GetService<AllReadyContext>();
Tenant htb = new Tenant()
{
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",
ManagingTenant = htb
};
htb.Campaigns.Add(firePrev);
Activity queenAnne = new Activity()
{
Id = 1,
Name = "Queen Anne Fire Prevention Day",
Campaign = firePrev,
CampaignId = firePrev.Id,
StartDateTimeUtc = new DateTime(2015, 7, 4, 10, 0, 0).ToUniversalTime(),
EndDateTimeUtc = new DateTime(2015, 12, 31, 15, 0, 0).ToUniversalTime(),
Location = new Location { Id = 1 },
Tenant = htb,
RequiredSkills = new List<ActivitySkill>()
};
context.Tenants.Add(htb);
context.Activities.Add(queenAnne);
context.SaveChanges();
}
示例5: GetCampaignsByPostalCodeReturnsCorrectResults
public void GetCampaignsByPostalCodeReturnsCorrectResults()
{
var activity1 = new Activity { Id = 1, CampaignId = 1 };
activity1.Campaign = new Campaign { Id = 1, Activities = new List<Activity> { activity1 }, ManagingOrganization = new Organization() };
var activity2 = new Activity { Id = 2 };
var activity3 = new Activity { Id = 3 };
var campaign2 = new Campaign { Id = 2, Activities = new List<Activity> { activity2, activity3 }, ManagingOrganization = new Organization() };
activity2.CampaignId = campaign2.Id;
activity2.Campaign = campaign2;
activity3.CampaignId = campaign2.Id;
activity3.Campaign = campaign2;
var allActivities = new List<Activity> { activity1, activity2, activity3 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<AcitivitiesByPostalCodeQuery>())).Returns(allActivities);
var sut = new CampaignApiController(mediator.Object);
var results = sut.GetCampaignsByPostalCode(It.IsAny<string>(), It.IsAny<int>());
Assert.Equal(results.Count(), allActivities.Count);
}
示例6: LoadTestData
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 = $"[email protected]";
var username2 = $"[email protected]";
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();
}
示例7: ExistingCampaign
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);
}
示例8: LoadTestData
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();
}
示例9: GetCampaignsByPostalCodeReturnsCorrectResults
public void GetCampaignsByPostalCodeReturnsCorrectResults()
{
var event1 = new Event { Id = 1, CampaignId = 1 };
event1.Campaign = new Campaign { Id = 1, Events = new List<Event> { event1 }, ManagingOrganization = new Organization() };
var event2 = new Event { Id = 2 };
var event3 = new Event { Id = 3 };
var campaign2 = new Campaign { Id = 2, Events = new List<Event> { event2, event3 }, ManagingOrganization = new Organization() };
event2.CampaignId = campaign2.Id;
event2.Campaign = campaign2;
event3.CampaignId = campaign2.Id;
event3.Campaign = campaign2;
var allEvents = new List<Event> { event1, event2, event3 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<EventsByPostalCodeQuery>())).Returns(allEvents);
var sut = new CampaignApiController(mediator.Object);
var results = sut.GetCampaignsByPostalCode(It.IsAny<string>(), It.IsAny<int>());
Assert.Equal(results.Count(), allEvents.Count);
}
示例10: LoadTestData
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 = $"[email protected]";
var username2 = $"[email protected]";
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();
}
示例11: SetOrganizationIdAndOrganizationName_WhenConstructingWithNonNullCampaignAndNonNullManagingOrganization
public void SetOrganizationIdAndOrganizationName_WhenConstructingWithNonNullCampaignAndNonNullManagingOrganization()
{
var campaign = new Campaign { ManagingOrganization = new Organization { Id = 1, Name = "OrgName" } };
var @event = new Event { Campaign = campaign };
var sut = new EventViewModel(@event);
Assert.Equal(sut.OrganizationId, campaign.ManagingOrganization.Id);
Assert.Equal(sut.OrganizationName, campaign.ManagingOrganization.Name);
}
示例12: CampaignByApplicationUserIdQueryHandlerShould
public CampaignByApplicationUserIdQueryHandlerShould()
{
message = new CampaignByApplicationUserIdQuery() { ApplicationUserId = Guid.NewGuid().ToString() };
campaign = new Campaign { Organizer = new ApplicationUser() { Id = message.ApplicationUserId } };
Context.Add(campaign);
Context.SaveChanges();
sut = new CampaignByApplicationUserIdQueryHandler(Context);
}
示例13: CampaignByCampaignIdQueryHandlerShould
public CampaignByCampaignIdQueryHandlerShould()
{
message = new CampaignByCampaignIdQuery { CampaignId = 1 };
campaign = new Campaign { Id = message.CampaignId, Published = true };
Context.Add(campaign);
Context.SaveChanges();
sut = new CampaignByCampaignIdQueryHandler(Context);
}
示例14: SetCampaignIdCampaignNameAndTimeZoneId_WhenConstructingWithNonNullCampaign
public void SetCampaignIdCampaignNameAndTimeZoneId_WhenConstructingWithNonNullCampaign()
{
var campaign = new Campaign { Id = 1, Name = "Campaignname", TimeZoneId = "CampaignTimeZoneId" };
var @event = new Event { Campaign = campaign, TimeZoneId = "EventTimeZoneId" };
var sut = new EventViewModel(@event);
Assert.Equal(sut.CampaignId, campaign.Id);
Assert.Equal(sut.CampaignName, campaign.Name);
Assert.Equal(sut.TimeZoneId, @event.TimeZoneId);
}
示例15: LoadTestData
protected override void LoadTestData()
{
var campaign = new Campaign
{
Id = 111,
ManagingOrganization = new Organization()
};
Context.Campaigns.Add(campaign);
Context.SaveChanges();
}