public void Given_Submitted_Checklist_When_Any_of_the_Action_is_Assigned_then_CanBeReverted_Returns_false()
        {
            var actionPlan = new ActionPlan() { Id = 1, Title = "My Action Plan", Deleted = false, };
            var action = new Action() { Id = 1, ActionPlanId = actionPlan.Id, ActionPlan = actionPlan, AssignedTo = new Employee() };

            var actionTasks = new List<ActionTask>();
            actionTasks.Add(new ActionTask() { Action = action} );

            action.ActionTasks = actionTasks;

            var actions = new List<Action>();
            actions.Add(action);
            actions.Add(new Action() { Id = 2, ActionPlanId = actionPlan.Id, ActionPlan = actionPlan, });
            actions.Add(new Action() { Id = 3, ActionPlanId = actionPlan.Id, ActionPlan = actionPlan, });

            actionPlan.Actions = actions;

            var checklist = new Checklist
            {
                Id = Guid.NewGuid(),
                ActionPlan = actionPlan,
                Status = "Submitted"
            };

            var target = checklist.CanBeReverted();

            Assert.IsFalse(target);
        }
        public void SetUp()
        {
            _emailSender = new Mock<IEmailSender>();
            _userRepository = new Mock<IUserRepository>();
            _taskRepository = new Mock<ITasksRepository>();

            _urlConfiguration = new Mock<IBusinessSafeEmailLinkBaseUrlConfiguration>();
            _urlConfiguration.Setup(x => x.GetBaseUrl()).Returns(string.Empty);
            _userRepository.Setup(x => x.GetById(It.IsAny<Guid>())).Returns(new User() 
                { Employee = new Employee() 
                    { ContactDetails = new List<EmployeeContactDetail>() 
                        { new EmployeeContactDetail() {Email = "*****@*****.**"}} } });

            _action = new BusinessSafe.Domain.Entities.Action()
            {
                ActionPlan = new ActionPlan(),
                ActionPlanId = 1,
                Id = 1,
                Category = ActionCategory.Action,
                ActionRequired = "You required this action",
            };

            _task = new ActionTask()
            {
                TaskAssignedTo = new Employee
                {
                    ContactDetails = new List<EmployeeContactDetail>() { new EmployeeContactDetail() { Email = "*****@*****.**" } }
                },
                CreatedBy = new UserForAuditing() { Id = Guid.NewGuid(),  },
                Title = "Action task title",
                Reference = "Action task reference",
                Action = _action,
            };

        }
        public void given_no_tasks_when_get_status_from_tasks_then_return_none()
        {
            // Given
            var action = new Action();

            // When
            var result = action.GetStatusFromTasks();

            // Then
            Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.None));
        }
        public void given_no_tasks_and_action_no_longer_required_when_get_status_from_tasks_then_return_no_longer_required()
        {
            // Given
            var action = new Action();
            action.NoLongerRequired = true;

            // When
            var result = action.GetStatusFromTasks();

            // Then
            Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.NoLongerRequired));
        }
        public void When_AssignAction_Task_Then_Calls_Correct_Methods()
        {
            //given
            var request = new AssignActionTaskRequest
                              {
                                  CompanyId = 1234L,
                                  UserId = Guid.NewGuid(),
                                  ActionId = 1L,
                                  AssignedTo = Guid.NewGuid(),
                                  DueDate = DateTime.Now
                              };

            var action = new Action
                             {
                                 Id = 1L,
                                 Title = "Action1",
                                 ActionPlan = new ActionPlan
                                                  {
                                                      Id = 1L,
                                                      Site = new Site
                                                                 {
                                                                     SiteId = 1L
                                                                 }
                                                  }
                             };

            _actionRepository.Setup(x => x.GetById(It.IsAny<long>())).Returns(action);
            _userForAuditingRepository.Setup(x => x.GetById(It.IsAny<Guid>())).Returns(new UserForAuditing{Id = Guid.NewGuid()});
            _employeeRepository.Setup(x => x.GetById(It.IsAny<Guid>())).Returns(new Employee { Id = Guid.NewGuid() });
            _siteRepository.Setup(x => x.GetById(It.IsAny<long>())).Returns(new Site {Id = 1L});
            _taskCategoryRepository.Setup(x => x.GetActionTaskCategory()).Returns(new TaskCategory {Id = 8});

            var target = GetTarget();

            //when
            target.AssignActionTask(request);

            //then
            _actionRepository.Verify(x => x.GetById(It.Is<long>(y => y == request.ActionId)));
            _userForAuditingRepository.Verify(x => x.GetById(It.Is<Guid>(y => y == request.UserId)));
            _employeeRepository.Verify(x=> x.GetById(It.Is<Guid>(y=>y == request.AssignedTo)));
            _siteRepository.Verify(x=>x.GetById(It.IsAny<long>()));
            _taskCategoryRepository.Verify(x => x.GetActionTaskCategory());
        }
        public void given_only_deleted_tasks_when_get_status_from_tasks_then_return_none()
        {
            // Given
            var action = new Action
                             {
                                 ActionTasks = new List<ActionTask>
                                                   {
                                                       new ActionTask()
                                                           {
                                                               Deleted = true,
                                                               TaskStatus = TaskStatus.Outstanding,
                                                               TaskCompletionDueDate = DateTime.Now
                                                           }
                                                   }
                             };

            // When
            var result = action.GetStatusFromTasks();

            // Then
            Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.None));
        }
         public void Given_Employee_is_assigned_a_task_then_return_task()
         {
             var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Daily};
             var actionTask = new ActionTask()
             {
                 TaskAssignedTo = employee,
                 TaskCompletedDate = null,
                 TaskCompletionDueDate = DateTime.Now.AddDays(-5)
             };

             var action = new BusinessSafe.Domain.Entities.Action();
             action.ActionTasks.Add(actionTask);             

             _actions.Add(action);

             var target = new GetOverdueActionTasksForEmployeeQuery(_queryableWrapper.Object);

             //WHEN
             var result = target.Execute(employee.Id, null);

             //THEN
             Assert.That(result.Count, Is.EqualTo(1));
         }
       public void Given_employee_is_asignee_and_notification_frequency_is_set_to_weekly_then_return_tasks_since_previous_week()
       {
           var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Weekly, NotificationFrequecy = (int)DayOfWeek.Wednesday };
           var action = new BusinessSafe.Domain.Entities.Action();
           
           action.ActionTasks.Add( new ActionTask()
           {
               TaskAssignedTo = employee,
               TaskCompletedDate = null,
               TaskCompletionDueDate = DateTime.Now.AddDays(-5)
           });

           action.ActionTasks.Add(new ActionTask()
           {
               TaskAssignedTo = employee,
               TaskCompletedDate = null,
               TaskCompletionDueDate = DateTime.Now.AddDays(-2)
           });

           action.ActionTasks.Add(new ActionTask()
           {
               TaskAssignedTo = employee,
               TaskCompletedDate = null,
               TaskCompletionDueDate = DateTime.Now.AddDays(-12)
           });

           _actions.Add(action);

           var target = new GetOverdueActionTasksForEmployeeQuery(_queryableWrapper.Object);

           //WHEN
           var result = target.Execute(employee.Id, null);

           //THEN
           Assert.That(result.Count, Is.EqualTo(2));
       }
        public void given_outstanding_tasks_when_get_status_from_tasks_then_return_outstanding()
        {
            // Given
            var action = new Action()
            {
                ActionTasks = new List<ActionTask>
                                                                              {
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Completed,
                                                                                      TaskCompletionDueDate = DateTime.Now.AddDays(1)
                                                                                  },
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Completed,
                                                                                      TaskCompletionDueDate = DateTime.Now
                                                                                  },
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Outstanding,
                                                                                      TaskCompletionDueDate = DateTime.Now.AddDays(1)
                                                                                  }
                                                                              }
            };

            var actionPlan = new ActionPlan {Actions = new List<Action> {action}};

            // When
            var result = actionPlan.GetStatusFromActions();

            // Then
            Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.Outstanding));
        }
        public void When_Search_Then_map_returned_entities_with_actions_to_dtos()
        {
            //given

            var actionPlan =
                new ActionPlan()
                    {
                        Id = 1234L,
                        CompanyId = 1L,
                        Title = "Action Plan1",
                        Site = new Site
                                   {
                                       SiteId = 1L
                                   },
                        DateOfVisit = DateTime.Now,
                        VisitBy = "Consultant1",
                        SubmittedOn = DateTime.Now.AddDays(-1),                       
                    };


            var action =
                new Action()
                    {
                        Id = 123123,
                        Title = "test title",
                        AreaOfNonCompliance = "area not compliant",
                        ActionRequired = "action required test",                        
                        TargetTimescale = "do this now",
                        AssignedTo = new Employee(){Id = Guid.NewGuid(), Forename = "Fred", Surname = "Flintstone"},
                        DueDate = DateTime.Now.AddDays(10),
                        Reference = "The Reference",
                        Category = ActionCategory.Action
                    };

            actionPlan.Actions = new List<Action>() {action};

            var target = GetTarget();

            _actionPlanRepository.Setup(
                x =>
                x.Search(It.IsAny<IList<long>>(),It.IsAny<long>(), It.IsAny<long?>(), It.IsAny<long?>(), It.IsAny<DateTime?>(),
                         It.IsAny<DateTime?>(), It.IsAny<bool>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<ActionPlanOrderByColumn>(),
                         It.IsAny<bool>())).Returns(new List<ActionPlan>() {actionPlan});

            //when
            var result = target.Search(new SearchActionPlanRequest());

            //then
            Assert.That(result.First().Actions.Count(), Is.GreaterThan(0));
            Assert.That(result.First().Actions.First().Id, Is.EqualTo(action.Id));  
            Assert.That(result.First().Actions.First().Title, Is.EqualTo(action.Title));  
            Assert.That(result.First().Actions.First().AreaOfNonCompliance, Is.EqualTo(action.AreaOfNonCompliance));  
            Assert.That(result.First().Actions.First().ActionRequired, Is.EqualTo(action.ActionRequired));       
            Assert.That(result.First().Actions.First().TargetTimescale, Is.EqualTo(action.TargetTimescale));              
            Assert.That(result.First().Actions.First().AssignedTo, Is.EqualTo(action.AssignedTo.Id));  
            Assert.That(result.First().Actions.First().DueDate, Is.EqualTo(action.DueDate));  
            Assert.That(result.First().Actions.First().Reference, Is.EqualTo(action.Reference));
            Assert.That(result.First().Actions.First().Category, Is.EqualTo(action.Category));   
        }
       public void Given_employee_is_assignee_and_notification_frequency_is_set_to_monthly_on_26th_then_return_tasks_since_26th_of_previous_month()
       {
           //GIVEN
           var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Monthly, NotificationFrequecy = 26 };
           
           var action = new BusinessSafe.Domain.Entities.Action();

           action.ActionTasks.Add(new ActionTask()
           {
               TaskAssignedTo = employee,
               TaskCompletedDate = null,
               TaskCompletionDueDate = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month, 27), //27th of last month,
               Title = "one"
           });

           action.ActionTasks.Add(new ActionTask()
           {
               TaskAssignedTo = employee,
               TaskCompletedDate = null,
               TaskCompletionDueDate = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month, 28), //28th of last month,
               Title = "two"
           });

           action.ActionTasks.Add(new ActionTask()
           {
               TaskAssignedTo = employee,
               TaskCompletedDate = null,
               TaskCompletionDueDate = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month, 23), //23th of last month,
               Title = "three"
           });

           _actions.Add(action);
           
           var target = new GetOverdueActionTasksForEmployeeQuery(_queryableWrapper.Object);

           //WHEN
           var result = target.Execute(employee.Id, null);
           //THEN
           Assert.That(result.Count, Is.EqualTo(2));
           Assert.That(result[0].Title, Is.EqualTo("one"));
           Assert.That(result[1].Title, Is.EqualTo("two"));
       }
        public void given_no_tasks_completed_and_action_no_longer_required_when_get_status_from_tasks_then_return_no_longer_required()
        {
            // Given
            var action = new Action()
            {
                ActionTasks = new List<ActionTask>
                                                                              {
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Overdue                                                                                      
                                                                                  },
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.NoLongerRequired,
                                                                                      TaskCompletionDueDate = DateTime.Now.AddDays(-1)
                                                                                  },
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = true,
                                                                                      TaskStatus = TaskStatus.Outstanding,
                                                                                      TaskCompletionDueDate = DateTime.Now.AddDays(-1)
                                                                                  }
                                                                              }
            };

            action.NoLongerRequired = true;

            // When
            var result = action.GetStatusFromTasks();

            // Then
            Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.NoLongerRequired));
        }
        public void given_outstanding_tasks_that_are_due_before_today_When_get_status_from_tasks_then_return_overdue()
        {
            // Given
            var action = new Action()
            {
                ActionTasks = new List<ActionTask>
                                                                              {
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Completed,
                                                                                      TaskCompletionDueDate = DateTime.Now.AddDays(1)
                                                                                  },
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Completed,
                                                                                      TaskCompletionDueDate = DateTime.Now
                                                                                  },
                                                                                  new ActionTask()
                                                                                  {
                                                                                      Deleted = false,
                                                                                      TaskStatus = TaskStatus.Outstanding,
                                                                                      TaskCompletionDueDate = DateTime.Now.AddDays(-1)
                                                                                  }
                                                                              }
            };

            // When
            var result = action.GetStatusFromTasks();

            // Then
            Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.Overdue));
        }
Exemplo n.º 14
0
        public void Given_a_checklist_exists_for_a_different_company_site_and_submit_is_true_When_PostChecklist_is_called_Then_otherchecklist_is_not_archived()
        {
            int clientId = 23456;

            //------------------------------------------------
             int siteOneID = 1111;
             Site siteOne = new Site { Id = 21L, SiteId = siteOneID };
             _siteRepository
                 .Setup(x => x.GetByPeninsulaSiteId((long)siteOneID))
                 .Returns(siteOne);

             Checklist siteOneChecklist = new Checklist();

             siteOneChecklist.Id = Guid.NewGuid();
             siteOneChecklist.SiteId = siteOneID;
             siteOneChecklist.ClientId = clientId;
             siteOneChecklist.Status = "Submitted";

             var actionPlanOneId = 234;
             siteOneChecklist.ActionPlan = new ActionPlan();
             siteOneChecklist.ActionPlan.Id = actionPlanOneId;

             Action action = new Action() { Id = 1, ActionPlanId = actionPlanOneId };

             action.ActionTasks = new List<ActionTask>();

             action.ActionTasks.Add(new ActionTask() { Id = 111, TaskStatus = TaskStatus.Outstanding });
             action.ActionTasks.Add(new ActionTask() { Id = 112, TaskStatus = TaskStatus.Overdue });
             action.ActionTasks.Add(new ActionTask() { Id = 113, TaskStatus = TaskStatus.Completed });

             siteOneChecklist.ActionPlan.Actions = new List<Action>();
             siteOneChecklist.ActionPlan.Actions.Add(action);

             //------------------------------------------------
             int siteTwoID = 2222;
             Site siteTwo = new Site { Id = 21L, SiteId = siteTwoID };
             _siteRepository
                 .Setup(x => x.GetByPeninsulaSiteId((long)siteTwoID))
                 .Returns(siteTwo);
             Checklist siteTwoChecklist = new Checklist();

             siteTwoChecklist.Id = Guid.NewGuid();
             siteTwoChecklist.SiteId = siteTwoID;
             siteTwoChecklist.ClientId = clientId;
             siteTwoChecklist.Status = "Submitted";

             var actionPlanTwoId = 234;
             siteTwoChecklist.ActionPlan = new ActionPlan();
             siteTwoChecklist.ActionPlan.Id = actionPlanTwoId;

             Action actionTwo = new Action() { Id = 2, ActionPlanId = actionPlanTwoId };

             actionTwo.ActionTasks = new List<ActionTask>();

             actionTwo.ActionTasks.Add(new ActionTask() { Id = 221, TaskStatus = TaskStatus.Outstanding });
             actionTwo.ActionTasks.Add(new ActionTask() { Id = 222, TaskStatus = TaskStatus.Overdue });
             actionTwo.ActionTasks.Add(new ActionTask() { Id = 223, TaskStatus = TaskStatus.Completed });

             siteTwoChecklist.ActionPlan.Actions = new List<Action>();
             siteTwoChecklist.ActionPlan.Actions.Add(action);

             //------------------------------------------------
             List<Checklist> checklists = new List<Checklist>();
             checklists.Add(siteOneChecklist);
             checklists.Add(siteTwoChecklist);

             _checklistRepository
                 .Setup(x => x.GetByClientId(clientId))
                 .Returns(checklists);

             Checklist savedSiteOneChecklist = null;
             _checklistRepository.Setup(x => x.SaveOrUpdate(siteOneChecklist))
                 .Callback(
                     delegate(Checklist x)
                     {
                         savedSiteOneChecklist = x;
                     }
                 );

             Checklist savedSiteTwoChecklist = null;
             _checklistRepository.Setup(x => x.SaveOrUpdate(siteTwoChecklist))
                 .Callback(
                     delegate(Checklist x)
                     {
                         savedSiteTwoChecklist = x;
                     }
                 );

             //Get view model
             var questions = GetListOfQuestions();
             var newChecklistViewModel = GetChecklistViewModelFromQuestions(questions);
             newChecklistViewModel.SiteId = siteTwoID;
             newChecklistViewModel.ClientId = clientId;
             newChecklistViewModel.Categories = new List<CategoryQuestionAnswerViewModel>();
             newChecklistViewModel.Questions = new List<QuestionAnswerViewModel>();
             newChecklistViewModel.CreatedOn = DateTime.Now;
             newChecklistViewModel.CreatedBy = "user";

             newChecklistViewModel.Submit = true;

             var controller = GetTarget();
             controller.Request = new HttpRequestMessage();
             controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

             var response = controller.PostChecklist(newChecklistViewModel.Id, newChecklistViewModel);

             Assert.That(savedSiteTwoChecklist.ActionPlan, Is.Not.Null);
             Assert.That(savedSiteTwoChecklist.ActionPlan.Actions[0], Is.Not.Null);
             Assert.AreEqual(true, savedSiteTwoChecklist.ActionPlan.NoLongerRequired);

             Assert.That(savedSiteOneChecklist, Is.Null);
        }
Exemplo n.º 15
0
        public void Given_a_checklist_already_exists_for_site_and_submit_is_true_When_PostChecklist_is_called_Then_previous_action_statuses_are_set_to_No_Longer_Required()
        {
            int clientId = 23456;

            int siteID = 1234;
            Site site = new Site { Id = 21L, SiteId = siteID };
            _siteRepository
                .Setup(x => x.GetByPeninsulaSiteId((long)siteID))
                .Returns(site);

            Checklist previousChecklist = new Checklist();
            previousChecklist.Id = Guid.NewGuid();
            previousChecklist.SiteId = siteID;
            previousChecklist.ClientId = clientId;
            previousChecklist.Status = "Submitted";

            var actionPlanId = 234;
            previousChecklist.ActionPlan = new ActionPlan();
            previousChecklist.ActionPlan.Id =actionPlanId;

            Action action = new Action() {Id = 1, ActionPlanId = actionPlanId};

            action.ActionTasks = new List<ActionTask>();

            action.ActionTasks.Add(new ActionTask() { Id = 123, TaskStatus = TaskStatus.Outstanding });
            action.ActionTasks.Add(new ActionTask() { Id = 123, TaskStatus = TaskStatus.Overdue });
            action.ActionTasks.Add(new ActionTask() { Id = 123, TaskStatus = TaskStatus.Completed });

            previousChecklist.ActionPlan.Actions = new List<Action>();
            previousChecklist.ActionPlan.Actions.Add(action);

            List<Checklist> checklists = new List<Checklist>();
            checklists.Add(previousChecklist);

            _checklistRepository
                .Setup(x => x.GetByClientId( clientId))
                .Returns(checklists);

            Checklist savedChecklist = null;
            _checklistRepository.Setup(x => x.SaveOrUpdate(previousChecklist))
                .Callback(
                    delegate(Checklist x)
                    {
                        savedChecklist = x;
                    }
                );

            //Get view model
            var questions = GetListOfQuestions();
            var newChecklistViewModel = GetChecklistViewModelFromQuestions(questions);
            newChecklistViewModel.SiteId = siteID;
            newChecklistViewModel.ClientId = clientId;
            newChecklistViewModel.Categories = new List<CategoryQuestionAnswerViewModel>();
            newChecklistViewModel.Questions = new List<QuestionAnswerViewModel>();
            newChecklistViewModel.CreatedOn = DateTime.Now;
            newChecklistViewModel.CreatedBy = "user";

            newChecklistViewModel.Submit = true;

            var controller = GetTarget();
            controller.Request = new HttpRequestMessage();
            controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var response = controller.PostChecklist(newChecklistViewModel.Id, newChecklistViewModel);

            Assert.That(savedChecklist.ActionPlan, Is.Not.Null);
            Assert.That(savedChecklist.ActionPlan.Actions[0], Is.Not.Null);

            Assert.AreEqual(3, savedChecklist.ActionPlan.Actions[0].ActionTasks.Count);
            Assert.AreEqual(TaskStatus.NoLongerRequired, savedChecklist.ActionPlan.Actions[0].ActionTasks[0].TaskStatus );
            Assert.AreEqual(TaskStatus.NoLongerRequired, savedChecklist.ActionPlan.Actions[0].ActionTasks[1].TaskStatus);
            Assert.AreEqual(TaskStatus.Completed, savedChecklist.ActionPlan.Actions[0].ActionTasks[2].TaskStatus);

            Assert.AreEqual(DerivedTaskStatusForDisplay.Completed, savedChecklist.ActionPlan.Actions[0].GetStatusFromTasks());
        }
        public void When_AssignAction_Task_Then_Saved_Action_With_Task()
        {
            //given
            var request = new AssignActionTaskRequest
            {
                CompanyId = 1234L,
                UserId = Guid.NewGuid(),
                ActionId = 1L,
                AssignedTo = Guid.NewGuid(),
                DueDate = DateTime.Now
            };

            var action = new Action
            {
                Id = 1L,
                ActionPlan = new ActionPlan
                {
                    Id = 1L,
                    Site = new Site
                    {
                        SiteId = 1L
                    }
                }
            };

            _actionRepository.Setup(x => x.GetById(It.IsAny<long>())).Returns(action);

            var target = GetTarget();

            //when
            target.AssignActionTask(request);

            //then
            _actionRepository.Verify(x => x.SaveOrUpdate(It.Is<Action>(a => a.Id == request.ActionId)));

        }
Exemplo n.º 17
0
        private void UpdateActionTask(AssignActionTaskRequest request, Employee employee, UserForAuditing user, TaskCategory taskCategory, Action action, Site site)
        {
            var createDocumentParameterObjects = request.Documents == null ? null : _documentParameterHelper.GetCreateDocumentParameters(request.Documents, request.CompanyId);

            if (action.ActionTasks.Any())
            {
                var task = action.ActionTasks.FirstOrDefault();
                task.Update(action.AreaOfNonCompliance,
                    action.ActionRequired,
                    request.DueDate,
                    TaskStatus.Outstanding,
                    employee,
                    user,
                    createDocumentParameterObjects, 
                    taskCategory,
                    (int) TaskReoccurringType.None,
                                        null,
                    request.SendTaskNotification,
                    request.SendTaskCompletedNotification,
                    request.SendTaskOverdueNotification,
                    request.SendTaskDueTomorrowNotification,
                    task.TaskGuid,
                    site
                    );
            }
            else
            {
                var task = new ActionTask();

                task = ActionTask.Create(
                    action.Reference,
                    action.AreaOfNonCompliance,
                    action.ActionRequired,
                    request.DueDate,
                    TaskStatus.Outstanding,
                    employee,
                    user,
                    createDocumentParameterObjects,
                    taskCategory,
                    (int) TaskReoccurringType.None,
                    null,
                    request.SendTaskNotification,
                    request.SendTaskCompletedNotification,
                    request.SendTaskOverdueNotification,
                    request.SendTaskDueTomorrowNotification,
                    Guid.NewGuid(),
                    site,
                    action
                    );
            }
        }