public void Given_a_request_where_previous_assessment_required_was_true_and_current_assessment_required_has_not_got_value_When_GetIsAssessmentRequired_Then_should_return_false()
        {
            // Arrange
            var request = new AddHazardousSubstanceRequest
            {
                PreviousAssessmentRequired = true,
                AssessmentRequired = null
            };

            // Act
            bool result = request.IsAssessmentRequired();

            // Assert
            Assert.False(result);
        }
        public ActionResult Add(AddHazardousSubstanceRequest request)
        {
            //server-side date validation as jQuery Datepicker fails with standard Range validation
            ValidateDates(request);
            if (!ModelState.IsValid)
            {
                var viewModel = _hazardousSubstanceViewModelFactory
                                    .WithCompanyId(request.CompanyId)
                                    .GetViewModel(request);
                return View("Add", viewModel);
            }

            request.UserId = CurrentUser.UserId;
            request.CompanyId = CurrentUser.CompanyId;


            var newHazardousSubstanceId = _hazardousSubstancesService.Add(request);

            if (request.IsAssessmentRequired())
            {
                return RedirectToAction("Create", "RiskAssessment", new { area = "HazardousSubstanceRiskAssessments", companyId = request.CompanyId, newHazardousSubstanceId });
            }

            return RedirectToAction("Index", "Inventory", new { companyId = request.CompanyId });


        }
        public ActionResult Update(AddHazardousSubstanceRequest request)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = _hazardousSubstanceViewModelFactory
                                    .WithCompanyId(request.CompanyId)
                                    .GetViewModel(request);
                return View("Add", viewModel);
            }

            request.UserId = CurrentUser.UserId;
            request.CompanyId = CurrentUser.CompanyId;
            _hazardousSubstancesService.Update(request);

            if (request.IsAssessmentRequired())
            {
                return RedirectToAction("Create", "RiskAssessment", new { area = "HazardousSubstanceRiskAssessments", companyId = request.CompanyId, newHazardousSubstanceId = request.Id });
            }

            return RedirectToAction("Index", "Inventory", new { companyId = request.CompanyId });

        }