public void Given_valid_further_control_measure_id_and_company_id_When_mark_further_actionTask_for_delete_Then_should_return_correct_result()
        {
            //Given
            var target = CreateController();
            var markTaskAsDeleteViewModel = new MarkTaskAsDeletedViewModel()
            {
                CompanyId = companyId,
                FurtherControlMeasureTaskId = taskId
            };

            //When
            var result = target.MarkTaskAsDeleted(markTaskAsDeleteViewModel);

            //Then
            dynamic data = result.Data;
            Assert.That(data.Success, Is.EqualTo(true));
        }
        public void Given_invalid_further_control_measure_id_and_company_id_When_mark_further_actionTask_for_delete_Then_should_throw_correct_exception()
        {
            //Given
            taskId = 0;
            companyId = 0;
            var target = CreateController();

            var markTaskAsDeleteViewModel = new MarkTaskAsDeletedViewModel()
            {
                CompanyId = companyId,
                FurtherControlMeasureTaskId = taskId
            };

            target.ModelState.AddModelError("", "");

            //When
            //Then
            Assert.Throws<ArgumentException>(() => target.MarkTaskAsDeleted(markTaskAsDeleteViewModel));
        }
        public void Given_valid_further_control_measure_id_and_company_id_When_mark_further_actionTask_for_delete_Then_should_call_appropiate_methods()
        {
            //Given
            var target = CreateController();

            var markTaskAsDeleteViewModel = new MarkTaskAsDeletedViewModel()
            {
                CompanyId = companyId,
                FurtherControlMeasureTaskId = taskId
            };

            //When
            target.MarkTaskAsDeleted(markTaskAsDeleteViewModel);

            //Then
            _taskService.Verify(x => x.MarkTaskAsDeleted(It.Is<MarkTaskAsDeletedRequest>(y => y.TaskId == taskId &&
                                                                                                                                   y.CompanyId == companyId &&
                                                                                                                                   y.UserId == target.CurrentUser.UserId)));
        }
        public JsonResult MarkTaskAsDeleted(MarkTaskAsDeletedViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                throw new ArgumentException("Invalid Arguments To Mark Task As Deleted");
            }

            var request = new MarkTaskAsDeletedRequest()
                              {
                                  TaskId = viewModel.FurtherControlMeasureTaskId,
                                  CompanyId = viewModel.CompanyId,
                                  UserId = CurrentUser.UserId
                              };

            if (_taskService.HasCompletedTasks(request))
            {
                return Json(new MarkTaskForDeleteResultViewModel()
                {
                    Success = false,
                    Message = "This reoccurring task has previous tasks which have been completed, and can therefore not be deleted."
                });
            }

            _taskService.MarkTaskAsDeleted(request);

            return Json(new MarkTaskForDeleteResultViewModel()
            {
                Success = true
            });
        }