protected ICollection <EpsilometerTest> EpsilometerTestsViewModelToModel(ICollection <EpsilometerTestViewModel> epsilometerTestViewModels)
        {
            var epsilometerTests = new List <EpsilometerTest>();

            foreach (var eTestViewModel in epsilometerTestViewModels)
            {
                if (HasValidETestValue(eTestViewModel))
                {
                    var eTest = new EpsilometerTest
                    {
                        EucastClinicalBreakpointId = eTestViewModel.EucastClinicalBreakpointId.Value,
                        Measurement = eTestViewModel.Measurement.Value,
                        Result      = eTestViewModel.Result.Value
                    };
                    epsilometerTests.Add(eTest);
                }
            }
            return(epsilometerTests);
        }
        private static void FillAntibiotic(IsolateCommon isolate, double?legacyMeasurement, DateTime receivingDate, Antibiotic antibiotic)
        {
            var db = Program.Context;

            if (!legacyMeasurement.HasValue)
            {
                return;
            }

            var measurement = (float)legacyMeasurement.Value;
            var minDate     = db.EucastClinicalBreakpoints.OrderByDescending(e => e.ValidFrom).Where(e => e.Antibiotic == antibiotic && e.ValidFor == DatabaseType.Meningococci)
                              .Min(e => e.ValidFrom);
            var eTestBreakPoint = db.EucastClinicalBreakpoints.OrderByDescending(e => e.ValidFrom)
                                  .First(e => (e.ValidFrom <= receivingDate || e.ValidFrom == minDate) && e.Antibiotic == antibiotic && e.ValidFor == DatabaseType.Meningococci);
            EpsilometerTestResult result;

            if (measurement > eTestBreakPoint.MicBreakpointResistent)
            {
                result = EpsilometerTestResult.Resistant;
            }
            else if (measurement <= eTestBreakPoint.MicBreakpointSusceptible)
            {
                result = EpsilometerTestResult.Susceptible;
            }
            else
            {
                result = EpsilometerTestResult.Intermediate;
            }

            var eTest = new EpsilometerTest
            {
                EucastClinicalBreakpoint = eTestBreakPoint,
                Measurement = measurement,
                Result      = result
            };

            isolate.EpsilometerTests.Add(eTest);
        }