public void Given_valid_request_When_update_control_measure_from_risk_assessment_Then_should_call_correct_methods()
        {
            //Given
            var target = CreateRiskAssessmentHazardService();
            var request = new UpdateControlMeasureRequest();

            var user = new UserForAuditing();
            _userRepo
                .Setup(x => x.GetByIdAndCompanyId(request.UserId, request.CompanyId))
                .Returns(user);

            var mockRiskAssessment = new Mock<GeneralRiskAssessment>();
            _riskAssessmentRepo
                .Setup(x => x.GetByIdAndCompanyId(request.RiskAssessmentId, request.CompanyId))
                .Returns(mockRiskAssessment.Object);

          
            //When
            target.UpdateControlMeasureForRiskAssessmentHazard(request);

            //Then
            _userRepo.VerifyAll();
            _riskAssessmentRepo.Verify(x => x.SaveOrUpdate(mockRiskAssessment.Object));
            mockRiskAssessment.Verify(x => x.UpdateControlMeasureForRiskAssessmentHazard(request.RiskAssessmentHazardId,request.ControlMeasureId, request.ControlMeasure,user));
        }
        public void Given_valid_request_When_UpdateControlMeasure_Then_should_call_correct_methods()
        {

            //Given
            var request = new UpdateControlMeasureRequest()
                              {
                                  ControlMeasureId = 500,
                                  CompanyId = 200,
                                  UserId = Guid.NewGuid(),
                                  RiskAssessmentId = 250,
                                  ControlMeasure = "Hello Control Measure"
                              };

            var mockRiskAssessment = new Mock<BusinessSafe.Domain.Entities.HazardousSubstanceRiskAssessment>();
            mockRiskAssessment
                .Setup(x => x.UpdateControlMeasure(request.ControlMeasureId, request.ControlMeasure, _user));

            _repository
                .Setup(x => x.GetByIdAndCompanyId(request.RiskAssessmentId, request.CompanyId)).
                Returns(mockRiskAssessment.Object);

            _repository
                .Setup(x => x.SaveOrUpdate(mockRiskAssessment.Object));

            _userRepository
                .Setup(x => x.GetByIdAndCompanyId(request.UserId, request.CompanyId))
                .Returns(_user);

            //When
            _target.UpdateControlMeasure(request);

            //Then
            _repository.VerifyAll();
            _userRepository.VerifyAll();
            mockRiskAssessment.Verify();
        }
        public void UpdateControlMeasureForRiskAssessmentHazard(UpdateControlMeasureRequest request)
        {
            _log.Add(request);

            try
            {
                var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);
                var riskAssessment = _riskAssessmentRepository.GetByIdAndCompanyId(request.RiskAssessmentId, request.CompanyId);

                riskAssessment.UpdateControlMeasureForRiskAssessmentHazard(request.RiskAssessmentHazardId, request.ControlMeasureId, request.ControlMeasure, user);
                _riskAssessmentRepository.SaveOrUpdate(riskAssessment);
            }
            catch (Exception ex)
            {
                _log.Add(ex);
                throw;
            }
        }
        public void UpdateControlMeasure(UpdateControlMeasureRequest request)
        {
            _log.Add(request);

            var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);
            var riskAssessment = _hazardousSubstanceRiskAssessmentRepository.GetByIdAndCompanyId(request.RiskAssessmentId, request.CompanyId);

            riskAssessment.UpdateControlMeasure(request.ControlMeasureId, request.ControlMeasure, user);

            _hazardousSubstanceRiskAssessmentRepository.SaveOrUpdate(riskAssessment);

        }