本文整理汇总了C#中AllReady.Models.AllReadyTask类的典型用法代码示例。如果您正苦于以下问题:C# AllReadyTask类的具体用法?C# AllReadyTask怎么用?C# AllReadyTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AllReadyTask类属于AllReady.Models命名空间,在下文中一共展示了AllReadyTask类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HasTaskEditPermissions
private async Task<bool> HasTaskEditPermissions(AllReadyTask task)
{
ApplicationUser currentUser = await _userManager.GetCurrentUser(Context);
IList<Claim> claims = await _userManager.GetClaimsForCurrentUser(Context);
if (claims.IsUserType(UserType.SiteAdmin))
{
return true;
}
if (claims.IsUserType(UserType.TenantAdmin))
{
//TODO: Modify to check that user is tenant admin for tenant of task
return true;
}
if (task.Activity != null && task.Activity.Organizer != null && task.Activity.Organizer.Id == currentUser.Id)
{
return true;
}
if (task.Activity != null && task.Activity.Campaign != null && task.Activity.Campaign.Organizer != null && task.Activity.Campaign.Organizer.Id == currentUser.Id)
{
return true;
}
return false;
}
开发者ID:rebeccacollins,项目名称:allReady,代码行数:27,代码来源:TaskApiController.cs
示例2: 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();
}
开发者ID:codethug,项目名称:allReady,代码行数:60,代码来源:MessageTaskVolunteersCommandHandlerAsyncTests.cs
示例3: LoadTestData
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 = $"[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.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();
}
开发者ID:weiplanet,项目名称:allReady,代码行数:60,代码来源:SignupStatusChange.cs
示例4: DetailsQueryHandlerShould
public DetailsQueryHandlerShould()
{
task = new AllReadyTask
{
Id = 1,
Name = "TaskName",
Description = "TaskDescription",
StartDateTime = DateTimeOffset.Now,
EndDateTime = DateTimeOffset.Now,
NumberOfVolunteersRequired = 5,
Event = new Event
{
Id = 2,
Name = "EventName",
CampaignId = 3,
Campaign = new Campaign { Id = 3, Name = "CampaignName", TimeZoneId = "Central Standard Time" }
},
RequiredSkills = new List<TaskSkill> { new TaskSkill { SkillId = 4, TaskId = 1 } },
AssignedVolunteers = new List<TaskSignup> { new TaskSignup { User = new ApplicationUser { Id = "UserId", UserName = "UserName" } } }
};
Context.Tasks.Add(task);
Context.SaveChanges();
message = new DetailsQuery { TaskId = task.Id };
sut = new DetailsQueryHandler(Context);
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:27,代码来源:DetailsQueryHandlerShould.cs
示例5: HasTaskEditPermissions
private bool HasTaskEditPermissions(AllReadyTask task)
{
var userId = User.GetUserId();
if (User.IsUserType(UserType.SiteAdmin))
{
return true;
}
if (User.IsUserType(UserType.OrgAdmin))
{
//TODO: Modify to check that user is organization admin for organization of task
return true;
}
if (task.Activity?.Organizer != null && task.Activity.Organizer.Id == userId)
{
return true;
}
if (task.Activity?.Campaign != null && task.Activity.Campaign.Organizer != null && task.Activity.Campaign.Organizer.Id == userId)
{
return true;
}
return false;
}
开发者ID:mmoore99,项目名称:allReady,代码行数:26,代码来源:TaskApiController.cs
示例6: SendNotificationToVolunteersWithCorrectMessage
public async Task SendNotificationToVolunteersWithCorrectMessage()
{
const string expectedMessage = "You've been assigned a task from AllReady.";
var @task = new AllReadyTask { Id = 1 };
var volunteer = new ApplicationUser
{
Id = "user1",
Email = "[email protected]",
PhoneNumber = "1234",
EmailConfirmed = true,
PhoneNumberConfirmed = true
};
Context.Add(volunteer);
Context.Add(@task);
Context.SaveChanges();
var message = new TaskAssignedToVolunteersNotification { TaskId = @task.Id, NewlyAssignedVolunteers = new List<string> { volunteer.Id } };
await sut.Handle(message);
mediator.Verify(b => b.SendAsync(It.Is<NotifyVolunteersCommand>(notifyCommand =>
notifyCommand.ViewModel.EmailMessage == expectedMessage &&
notifyCommand.ViewModel.Subject == expectedMessage &&
notifyCommand.ViewModel.EmailRecipients.Contains(volunteer.Email) &&
notifyCommand.ViewModel.SmsRecipients.Contains(volunteer.PhoneNumber) &&
notifyCommand.ViewModel.SmsMessage == expectedMessage
)), Times.Once());
}
开发者ID:stevejgordon,项目名称:allReady,代码行数:28,代码来源:NotifyAssignedVolunteersForTheTaskShould.cs
示例7: EditTaskQueryHandlerShould
public EditTaskQueryHandlerShould()
{
task = new AllReadyTask
{
Id = 1,
Name = "Taskname",
Description = "Description",
StartDateTime = DateTimeOffset.Now,
EndDateTime = DateTimeOffset.Now,
NumberOfVolunteersRequired = 5,
RequiredSkills = new List<TaskSkill> { new TaskSkill { SkillId = 2, Skill = new Skill(), TaskId = 1 } },
Event = new Event
{
Id = 3,
Name = "EventName",
CampaignId = 4,
Campaign = new Campaign
{
StartDateTime = DateTimeOffset.Now,
EndDateTime = DateTimeOffset.Now,
Name = "CampaignName",
ManagingOrganizationId = 5,
TimeZoneId = "Central Standard Time"
}
}
};
Context.Tasks.Add(task);
Context.SaveChanges();
message = new EditTaskQuery { TaskId = task.Id };
sut = new EditTaskQueryHandler(Context);
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:34,代码来源:EditTaskQueryHandlerShould.cs
示例8: IsClosed_ShouldBeTrue_IfEndDatePriorToCurrentDate
public void IsClosed_ShouldBeTrue_IfEndDatePriorToCurrentDate()
{
var sut = new AllReadyTask();
sut.EndDateTime = DateTime.UtcNow.AddDays(-1);
Assert.True(sut.IsClosed);
}
开发者ID:codethug,项目名称:allReady,代码行数:8,代码来源:AllReadyTaskTests.cs
示例9: OrganizationIdByTaskIdQueryHandlerShould
public OrganizationIdByTaskIdQueryHandlerShould()
{
task = new AllReadyTask { Id = TaskId, Organization = new Organization { Id = OrganizationId } };
Context.Tasks.Add(task);
Context.Tasks.Add(new AllReadyTask { Id = 2 });
Context.SaveChanges();
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:8,代码来源:OrganizationIdByTaskIdQueryHandlerShould.cs
示例10: IsClosed_ShouldBeFalse_IfEndDateLaterThanCurrentDate
public void IsClosed_ShouldBeFalse_IfEndDateLaterThanCurrentDate()
{
var sut = new AllReadyTask();
sut.EndDateTime = DateTime.UtcNow.AddDays(1);
Assert.False(sut.IsClosed);
}
开发者ID:codethug,项目名称:allReady,代码行数:8,代码来源:AllReadyTaskTests.cs
示例11: 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();
}
开发者ID:ChrisDobby,项目名称:allReady,代码行数:58,代码来源:MessageEventVolunteersCommandHandlerTests.cs
示例12: TaskViewModel
public TaskViewModel(AllReadyTask task, string userId = null)
{
Id = task.Id;
Name = task.Name;
Description = task.Description;
StartDateTime = task.StartDateTime;
EndDateTime = task.EndDateTime;
if (task.Event != null)
{
EventId = task.Event.Id;
eventName = task.Event.Name;
}
if (task.Event?.Campaign != null)
{
CampaignId = task.Event.Campaign.Id;
CampaignName = task.Event.Campaign.Name;
}
if (task.Organization != null)
{
OrganizationId = task.Organization.Id;
OrganizationName = task.Organization.Name;
}
IsUserSignedUpForTask = false;
if (task.AssignedVolunteers != null)
{
if (!string.IsNullOrWhiteSpace(userId))
{
IsUserSignedUpForTask = task.AssignedVolunteers.Any(au => au.User.Id == userId);
}
AssignedVolunteers = new List<TaskSignupViewModel>();
if (IsUserSignedUpForTask)
{
foreach (var t in task.AssignedVolunteers.Where(au => au.User.Id == userId))
{
AssignedVolunteers.Add(new TaskSignupViewModel(t));
}
}
}
if (task.RequiredSkills != null)
{
RequiredSkills = task.RequiredSkills.Select(t => t.SkillId);
RequiredSkillObjects = task.RequiredSkills?.Select(t => t.Skill).Select(s => new SkillViewModel(s)).ToList();
}
NumberOfVolunteersRequired = task.NumberOfVolunteersRequired;
NumberOfUsersSignedUp = task.NumberOfUsersSignedUp;
IsLimitVolunteers = task.IsLimitVolunteers;
IsAllowWaitList = task.IsAllowWaitList;
IsClosed = task.IsClosed;
}
开发者ID:gftrader,项目名称:allReady,代码行数:58,代码来源:TaskViewModel.cs
示例13: InvalidOperationException
Task IAllReadyDataAccess.AddTaskAsync(AllReadyTask task)
{
if (task.Id == 0)
{
_dbContext.Add(task);
return _dbContext.SaveChangesAsync();
}
else throw new InvalidOperationException("Added task that already has Id");
}
开发者ID:ultrabert,项目名称:allReady,代码行数:9,代码来源:AllReadyDataAccessEF7.Task.cs
示例14:
Task IAllReadyDataAccess.UpdateTaskAsync(AllReadyTask value)
{
//First remove any skills that are no longer associated with this task
var tsToRemove = _dbContext.TaskSkills.Where(ts => ts.TaskId == value.Id && (value.RequiredSkills == null ||
!value.RequiredSkills.Any(ts1 => ts1.SkillId == ts.SkillId)));
_dbContext.TaskSkills.RemoveRange(tsToRemove);
_dbContext.Tasks.Update(value);
return _dbContext.SaveChangesAsync();
}
开发者ID:ultrabert,项目名称:allReady,代码行数:9,代码来源:AllReadyDataAccessEF7.Task.cs
示例15: TaskViewModel
public TaskViewModel(AllReadyTask task)
{
Id = task.Id;
Name = task.Name;
Description = task.Description;
if (task.StartDateTimeUtc.HasValue)
{
DateTime startDateWithUtcKind = DateTime.SpecifyKind(
DateTime.Parse(task.StartDateTimeUtc.Value.ToString()),
DateTimeKind.Utc);
StartDateTime = new DateTimeOffset(startDateWithUtcKind);
}
if (task.EndDateTimeUtc.HasValue)
{
DateTime endDateWithUtcKind = DateTime.SpecifyKind(
DateTime.Parse(task.EndDateTimeUtc.Value.ToString()),
DateTimeKind.Utc);
EndDateTime = new DateTimeOffset(endDateWithUtcKind);
}
if (task.Activity != null)
{
ActivityId = task.Activity.Id;
ActivityName = task.Activity.Name;
}
if (task.Activity != null && task.Activity.Campaign != null)
{
CampaignId = task.Activity.Campaign.Id;
CampaignName = task.Activity.Campaign.Name;
}
if (task.Tenant != null)
{
TenantId = task.Tenant.Id;
TenantName = task.Tenant.Name;
}
IsUserSignedUpForTask = false;
if (task.AssignedVolunteers != null)
{
this.AssignedVolunteers = new List<TaskSignupViewModel>();
foreach (var t in task.AssignedVolunteers)
{
this.AssignedVolunteers.Add(new TaskSignupViewModel(t));
}
}
if (task.RequiredSkills != null)
{
this.RequiredSkills = task.RequiredSkills.Select(t => t.SkillId);
}
}
开发者ID:ResaWildermuth,项目名称:allReady,代码行数:56,代码来源:TaskViewModel.cs
示例16: UpdateExistingTaskSuccessfully
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);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:55,代码来源:EditTaskCommandHandlerAsyncShould.cs
示例17: TasksByApplicationUserIdQueryHandlerShould
public TasksByApplicationUserIdQueryHandlerShould()
{
message = new TasksByApplicationUserIdQuery { ApplicationUserId = Guid.NewGuid().ToString() };
alreadyTask = new AllReadyTask { Name = "name" };
task = new TaskSignup { User = new ApplicationUser { Id = message.ApplicationUserId }, Task = alreadyTask };
Context.Add(alreadyTask);
Context.Add(task);
Context.SaveChanges();
sut = new TasksByApplicationUserIdQueryHandler(Context);
}
开发者ID:HTBox,项目名称:allReady,代码行数:12,代码来源:TasksByApplicationUserIdQueryHandlerShould.cs
示例18: AssignsVolunteersToTask
public async Task AssignsVolunteersToTask()
{
var newVolunteer = new ApplicationUser { Id = "user1", Email = "[email protected]", PhoneNumber = "1234"};
var task = new AllReadyTask { Id = 1 };
Context.Add(newVolunteer);
Context.Add(task);
Context.SaveChanges();
var message = new AssignTaskCommand { TaskId = task.Id, UserIds = new List<string> { newVolunteer.Id } };
await sut.Handle(message);
var taskSignup = Context.Tasks.Single(x => x.Id == task.Id).AssignedVolunteers.Single();
Assert.Equal(taskSignup.User.Id, newVolunteer.Id);
Assert.Equal(taskSignup.Status, TaskStatus.Assigned.ToString());
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:15,代码来源:AssignTaskCommandHandlerShould.cs
示例19: LoadTestData
protected override void LoadTestData()
{
var user = new ApplicationUser { Id = "abc" };
Context.Users.Add(user);
var campaignEvent = new Event { Id = 1, Name = "Some Event" };
Context.Events.Add(campaignEvent);
var @task = new AllReadyTask { Id = 1, Name = "Some Task", EndDateTime = DateTime.UtcNow.AddDays(100), Event = campaignEvent };
Context.Tasks.Add(@task);
Context.TaskSignups.Add(new TaskSignup { Task = @task, User = user });
Context.SaveChanges();
}
开发者ID:stevejgordon,项目名称:allReady,代码行数:15,代码来源:TaskUnenrollHandlerShould.cs
示例20: HasTaskSignupEditPermissions
private async Task<bool> HasTaskSignupEditPermissions(AllReadyTask task)
{
if (await HasTaskEditPermissions(task))
{
return true;
}
else
{
ApplicationUser currentUser = await _userManager.GetCurrentUser(Context);
if (task.AssignedVolunteers != null && task.AssignedVolunteers.FirstOrDefault(x => x.User.Id == currentUser.Id) != null)
{
return true;
}
else { return false; }
}
}
开发者ID:rebeccacollins,项目名称:allReady,代码行数:16,代码来源:TaskApiController.cs
注:本文中的AllReady.Models.AllReadyTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论