private static bool IsTaskDue(ResponsibilityTask task) { return ( (task.TaskAssignedTo.NotificationType == NotificationType.Daily && task.TaskCompletionDueDate.HasValue && QueriesHelper.SimplifyDate(task.TaskCompletionDueDate.Value) == QueriesHelper.SimplifyDate(DateTime.Now.AddDays(1))) || (task.TaskAssignedTo.NotificationType == NotificationType.Weekly && task.TaskCompletionDueDate.HasValue && task.TaskCompletionDueDate.Value < DateTime.Now.AddDays(7)) || (task.TaskAssignedTo.NotificationType == NotificationType.Monthly && task.TaskCompletionDueDate.HasValue && task.TaskCompletionDueDate.Value < DateTime.Now.AddDays(30))); }
public ResponsibilityTaskDto MapWithAssignedTo(ResponsibilityTask entity) { var dto = new ResponsibilityTaskDto(); dto = PopulateTaskDto(entity, dto) as ResponsibilityTaskDto; dto.StatutoryResponsibilityTaskTemplateCreatedFrom = new StatutoryResponsibilityTaskTemplateDtoMapper().Map( entity.StatutoryResponsibilityTaskTemplateCreatedFrom); return dto; }
public void Given_task_SendTaskCompletedNotification_is_false_When_IsTaskCompletedNotificationRequired_Then_return_false() { // Given responsibilityTask = new ResponsibilityTask() { Responsibility = _responsibility.Object, SendTaskCompletedNotification = false }; // When var result = responsibilityTask.IsTaskCompletedNotificationRequired(); // Then Assert.IsFalse(result); }
public void Given_task_has_all_requirements_When_IsTaskCompletedNotificationRequired_Then_return_true() { // Given responsibilityTask = new ResponsibilityTask() { Responsibility = _responsibility.Object, SendTaskCompletedNotification = true }; // When var result = responsibilityTask.IsTaskCompletedNotificationRequired(); // Then Assert.IsTrue(result); }
public void Given_tasks_RiskAssessor_does_not_have_contact_details_is_false_When_IsTaskCompletedNotificationRequired_Then_return_false() { // Given _responsibilityOwner.Setup(x => x.GetEmail()); responsibilityTask = new ResponsibilityTask() { Responsibility = _responsibility.Object, SendTaskCompletedNotification = true }; // When var result = responsibilityTask.IsTaskCompletedNotificationRequired(); // Then Assert.IsFalse(result); }
public void Given_a_responsibilitytask_when_Map_then_properties_are_mapped() { //Given var entity = new ResponsibilityTask { }; //When var result = ResponsibilityTaskDtoMapper.Map(entity); //Act Assert.That(result.Id, Is.EqualTo(entity.Id)); Assert.That(result.CompanyId, Is.EqualTo(entity.CompanyId)); }
public static ResponsibilityTask Create(string title, string description, DateTime? taskCompletionDueDate, TaskStatus taskStatus, Employee assignedTo, UserForAuditing user, IEnumerable<CreateDocumentParameters> createDocumentParameterObjects, TaskCategory taskCategory, int taskReoccurringTypeId, DateTime? taskReoccurringEndDate, bool sendTaskNotification, bool sendTaskCompletedNotification, bool sendTaskOverdueNotification, bool sendTaskDueTomorrowNotification, Guid taskGuid, Site site, Responsibility responsibility) { var task = new ResponsibilityTask(); task.SetValuesForCreate( string.Empty, title, description, taskCompletionDueDate, taskStatus, assignedTo, user, createDocumentParameterObjects, taskCategory, taskReoccurringTypeId, taskReoccurringEndDate, sendTaskNotification, sendTaskCompletedNotification, sendTaskOverdueNotification, sendTaskDueTomorrowNotification, taskGuid, site); task.Responsibility = responsibility; responsibility.AddTask(task); responsibility.SetLastModifiedBy(user); return task; }
private static bool DoesTaskNeedToBeNotified(ResponsibilityTask task, Guid employeeId) { // Risk Assessor if (task.TaskAssignedTo != null && task.TaskAssignedTo.Id == employeeId) { var notificationType = task.TaskAssignedTo.NotificationType; var notificationFrequency = task.TaskAssignedTo.NotificationFrequecy; return ( (notificationType == NotificationType.Daily || (notificationType == NotificationType.Weekly && task.TaskCompletionDueDate.HasValue && QueriesHelper.SimplifyDate(task.TaskCompletionDueDate.Value) >= QueriesHelper.SimplifyDate(DateTime.Now.AddDays(-7))) || (notificationType == NotificationType.Monthly && task.TaskCompletionDueDate.HasValue && notificationFrequency.HasValue && QueriesHelper.SimplifyDate(task.TaskCompletionDueDate.Value) >= QueriesHelper.GetPreviousMonthsDate(notificationFrequency.Value))) ); } else { return false; } }
public void Given_Employee_is_assigned_a_task_then_return_task() { var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Daily}; var responsibilityTask = new ResponsibilityTask() { TaskAssignedTo = employee, TaskCompletionDueDate = DateTime.Now.AddDays(-5) }; var responsibility = new Responsibility(){ }; responsibility.ResponsibilityTasks.Add(responsibilityTask); _responsibilities.Add(responsibility); var target = new GetOverdueResponsibilitiesTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(1)); }
public void Given_Employee_is_assignee_task_due_in_2_days_and_notified_daily_then_dont_return_due_tomorrow_responsibility_task() { var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Daily }; var responsibilityTask = new ResponsibilityTask() { TaskAssignedTo = employee, TaskStatus = TaskStatus.Outstanding, TaskCompletedDate = null, TaskCompletionDueDate = DateTime.Now.AddDays(2) }; var responsibility = new Responsibility() { }; responsibility.ResponsibilityTasks.Add(responsibilityTask); _responsibilities.Add(responsibility); var target = new GetDueResponsibilityTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(0)); }
public void Given_tasks_RiskAssessor_email_is_null_When_IsTaskCompletedNotificationRequired_Then_return_false() { // Given _responsibilityOwner.Setup(x => x.HasEmail).Returns(false); responsibilityTask = new ResponsibilityTask() { Responsibility = _responsibility.Object, SendTaskCompletedNotification = true }; // When var result = responsibilityTask.IsTaskCompletedNotificationRequired(); // Then Assert.IsFalse(result); }
public void Given_notification_set_to_weekly_and_task_is_due_in_less_than_a_week_return_task() { var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Weekly}; var responsibilityTask = new ResponsibilityTask() { TaskAssignedTo = employee, TaskStatus = TaskStatus.Outstanding, TaskCompletedDate = null, TaskCompletionDueDate = DateTime.Now.AddDays(5) }; var responsibility = new Responsibility() { }; responsibility.ResponsibilityTasks.Add(responsibilityTask); _responsibilities.Add(responsibility); var target = new GetDueResponsibilityTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(1)); }
private void SetResponsibilityTaskValuesFromTemplate(long statutoryResponsibilityTaskTemplateId, ResponsibilityTask task) { var template = _statutoryResponsibilityTaskTemplateRepository.GetById(statutoryResponsibilityTaskTemplateId); if (template != null) { task.Title = template.Title; task.Description = template.Description; task.StatutoryResponsibilityTaskTemplateCreatedFrom = template; } }