public AssayDTO AddAssay(AssayDTO assayDto) { var assay = new Assay(); //var project = _projectRepository.FindSingle(d => d.Accession // .Equals(assayDto.ProjectAcc)); assay.Name = assayDto.Name; assay.ProjectId = assayDto.ProjectId; assay.TechnologyPlatformId = assayDto.Platform; assay.TechnologyTypeId = assayDto.Technology; //assay.DesignType = getCVterm(assayDto.AssayDesignType); assay.MeasurementTypeId = assayDto.Type; if (assayDto.SamplesDataset != null) { assayDto.SamplesDataset.ProjectId = assayDto.ProjectId; } if (assayDto.FeaturesDataset != null) { assayDto.FeaturesDataset.ProjectId = assayDto.ProjectId; } if (assayDto.ObservationsDataset != null) { assayDto.ObservationsDataset.ProjectId = assayDto.ProjectId; } var BSdataset = _datasetDescriptorService.CreateDataset(assayDto.SamplesDataset); if (BSdataset != null) { assay.Datasets.Add(BSdataset); } var FEdataset = _datasetDescriptorService.CreateDataset(assayDto.FeaturesDataset); if (FEdataset != null) { assay.Datasets.Add(FEdataset); } var OBdataset = _datasetDescriptorService.CreateDataset(assayDto.ObservationsDataset); if (OBdataset != null) { assay.Datasets.Add(OBdataset); } assay = _assayRepository.Insert(assay); if (_dataContext.Save().Equals("CREATED")) { assayDto.Id = assay.Id; return(assayDto); } return(null); }
public ActivityDTO AddActivity(ActivityDTO activityDTO) { //var project = _projectRepository.FindSingle(d => d.Accession // .Equals(activityDTO.ProjectAcc)); var activity = new Activity { Name = activityDTO.Name, ProjectId = activityDTO.ProjectId }; foreach (var datasetDto in activityDTO.datasets) { datasetDto.ProjectId = activityDTO.ProjectId; var dataset = _datasetDescriptorService.CreateDataset(datasetDto); activity.Datasets.Add(dataset); } activity = _activityRepository.Insert(activity); if (_activityServiceUnit.Save().Equals("CREATED")) { activityDTO.Id = activity.Id; return(activityDTO); } return(null); }