public ESDATDataDisplayViewModel GetSampleCollectionActionInESDAT(int Id, int?version = null)
        {
            var mappingHelper = new ESDATViewModelMappingHelper();
            var versionHelper = new DataVersioningHelper(_wqDefaultValueProvider);

            var matchedAction = _wqDataRepository.GetActionById(Id);

            var esdatModel = Mapper.Map <ESDATDataDisplayViewModel>(matchedAction);

            //no version function is applied to chemistry data yet
            esdatModel.ChemistryData = ESDATViewModelMappingHelper.MapActionToChemistryFileData(matchedAction, versionHelper);

            if (version.HasValue)
            {
                esdatModel.CurrentSampleDataVersion = version.Value;
                if (version.Value == 0)
                {
                    esdatModel.SampleFileData = ESDATViewModelMappingHelper.MapActionToSampleFileData(matchedAction);
                }
                else if (version.Value >= 1)
                {
                    while (version >= 1)
                    {
                        var nextVersion = versionHelper.GetNextVersionActionData(matchedAction);
                        if (nextVersion == null)
                        {
                            throw new ArgumentException();
                        }
                        matchedAction = nextVersion;
                        version--;
                    }
                }
                else
                {
                    throw new ArgumentException();
                }


                esdatModel.SampleFileData = ESDATViewModelMappingHelper.MapActionToSampleFileData(matchedAction);
            }
            else
            {
                //show the latest version data by default
                var numberOfSubversions = versionHelper.GetSubVersionCountOfAction(matchedAction);
                matchedAction = versionHelper.GetLatestVersionActionData(matchedAction);

                esdatModel.CurrentSampleDataVersion = numberOfSubversions;
                esdatModel.SampleFileData           = ESDATViewModelMappingHelper.MapActionToSampleFileData(matchedAction);
            }

            return(esdatModel);
        }
        public IEnumerable <ChemistryDataEditViewModel> GetChemistryAnalyteDataBySampleActionId(int Id)
        {
            var mappingHelper = new ESDATViewModelMappingHelper();
            var versionHelper = new DataVersioningHelper(_wqDefaultValueProvider);

            var matchedAction = _wqDataRepository.GetActionById(Id);

            if (matchedAction != null)
            {
                var viewModels = ESDATViewModelMappingHelper.MapActionToChemistryFileEditViewModel(matchedAction, versionHelper);
                return(viewModels);
            }
            else
            {
                return(null);
            }
        }