public virtual void UpdateAssessmentDetails(
     Quantity? quantity,
     MatterState? matterState,
     DustinessOrVolatility? dustinessOrVolatility,
     bool healthSurveillanceRequired,
     UserForAuditing currentUser)
 {
     Quantity = quantity;
     MatterState = matterState;
     DustinessOrVolatility = dustinessOrVolatility;
     HealthSurveillanceRequired = healthSurveillanceRequired;
     SetLastModifiedDetails(currentUser);
 }
        public ControlSystem Calculate(string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility)
        {
            if (hazardousSubstanceGroupCode == null || !matterState.HasValue || !quantity.HasValue || !dustinessOrVolatility.HasValue)
                return _controlSystemRepository.GetById((long)ControlSystemEnum.None);

            var rules = GetHazardousSubstanceGroupRules();
            var rule = rules.FirstOrDefault(h => h.Group == hazardousSubstanceGroupCode && h.MatterState == matterState && h.Quantity == quantity && h.DustinessOrVolatility == dustinessOrVolatility);

            if(rule == null)
            {
                throw new NoneMatchingControlSystemRuleException(hazardousSubstanceGroupCode, matterState, quantity,
                                                                 dustinessOrVolatility);
            }

            return _controlSystemRepository.GetById((long)rule.ControlSystem);
        }
        public JsonResult GetControlSystem(long riskAssessmentId, string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility)
        {
            var controlSystemDto = _controlSystemService.Calculate(hazardousSubstanceGroupCode, matterState, quantity, dustinessOrVolatility);

            _hazardousSubstanceRiskAssessmentService.SaveLastRecommendedControlSystem(new SaveLastRecommendedControlSystemRequest
                                                                                          {
                                                                                              Id = riskAssessmentId,
                                                                                              CompanyId = CurrentUser.CompanyId,
                                                                                              ControlSystemId = controlSystemDto.Id,
                                                                                              UserId = CurrentUser.UserId
                                                                                          });

            var url = Url.Action("LoadControlSystem", new { controlSystem = controlSystemDto.Description });


            return Json(new
            {
                ControlSystemId = controlSystemDto.Id,
                ControlSystem = controlSystemDto.Description,
                Url = url
            }, JsonRequestBehavior.AllowGet);
        }
        public void Given_various_parameters_When_calculate_called_Then_returns_correct_control_system(
            string hazardGroupCode, 
            MatterState? matterState, 
            Quantity? quantity, 
            DustinessOrVolatility? dustinessOrVolatility,
            string expectedDescription)
        {
            //When
            var controlSystemCalculationService = new ControlSystemCalculationService(_repository.Object);
            var controlSystem = controlSystemCalculationService.Calculate(hazardGroupCode, matterState, quantity,
                                                                          dustinessOrVolatility);

            //Then
            Assert.AreEqual(expectedDescription, controlSystem.Description);
        }
 public HazardousSubstanceGroupRule(string group, MatterState matterState, Quantity quantity, DustinessOrVolatility dustinessOrVolatility, ControlSystemEnum controlSystem)
 {
     Group = group;
     MatterState = matterState;
     Quantity = quantity;
     DustinessOrVolatility = dustinessOrVolatility;
     ControlSystem = controlSystem;
 }
 public NoneMatchingControlSystemRuleException(string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility)
     : base(string.Format("No matching control system rule configured. Hazardous Substance Group Code is {0}. MatterStateId is {1}. QuantityId is {2}. DustinessOrVolatileId is {3}.", hazardousSubstanceGroupCode, matterState.GetValueOrDefault(),quantity.GetValueOrDefault(),dustinessOrVolatility.GetValueOrDefault()))
 {}
Ejemplo n.º 7
0
        public void Given_a_HSRA_when_copy_then_DustinessOrVolatility_is_set(DustinessOrVolatility dustinessOrVolatility)
        {
            //Given
            var user = new UserForAuditing();
            var riskAssessment = HazardousSubstanceRiskAssessment.Create("new title", "new reference", 1, user, new HazardousSubstance());
            riskAssessment.DustinessOrVolatility = dustinessOrVolatility;

            //When
            var result = riskAssessment.Copy("Test Clone Reference", "", user) as HazardousSubstanceRiskAssessment;

            //Then
            Assert.That(result.DustinessOrVolatility, Is.EqualTo(dustinessOrVolatility));
        }
 public ControlSystemDto Calculate(string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility)
 {
     var controlSystem = _controlSystemCalculationService.Calculate(hazardousSubstanceGroupCode, matterState, quantity, dustinessOrVolatility);
     return new ControlSystemDtoMapper().Map(controlSystem);
 }