private static DataCollection GetDataCollection(SqlConnection conn, int id)
 {
     DataCollection collection = null;
     using (var command = new SqlCommand(string.Format(ConstSqlGetDatacollection, id), conn))
     {
         using (var reader = command.ExecuteReader())
         {
             if (reader.Read())
             {
                 collection = new DataCollection
                                  {
                                      Id = reader.GetValue<int>("Id"),
                                      ProjectId = reader.GetValue<int>("ProjectId"),
                                      Title = reader.GetStringValue("Title"),
                                      ResearchDataDescription = reader.GetStringValue("ResearchDataDescription"),
                                      StartDate = reader.GetValue<DateTime>("StartDate"),
                                      EndDate = reader.GetValue<DateTime>("EndDate"),
                                      Type = reader.GetEnumValue<DataCollectionType>("Type"),
                                      DataLicensingRights = reader.GetEnumValue<DataLicensingType>("DataLicensingRights"),
                                      ShareAccess = reader.GetEnumValue<ShareAccess>("ShareAccess"),
                                      ShareAccessDescription = reader.GetStringValue("ShareAccessDescription"),
                                      Keywords = reader.GetStringValue("Keywords"),
                                      Availability = reader.GetEnumValue<DataSharingAvailability>("Availability"),
                                      AvailabilityDate = reader.GetNullableValue<DateTime>("AvailabilityDate"),
                                      DataCollectionIdentifier = reader.GetValue<DataCollectionIdentifier>("DataCollectionIdentifier"),
                                      DataCollectionIdentifierValue = reader.GetStringValue("DataCollectionIdentifierValue")
                                  };
             }
         }
     }
     return collection;
 }
 private static void PopulateForCodes(SqlConnection conn, DataCollection dataCollection)
 {
     var cmd = new SqlCommand(string.Format(ConstSqlGetFor, dataCollection.Id), conn);
     
     using (var sqlReader = cmd.ExecuteReader())
     {
         while (sqlReader.Read())
         {
             var dataCollectionFieldOfResearchId = sqlReader.GetStringValue("FieldOfResearchId");
             dataCollection.FieldsOfResearch.Add(new DataCollectionFieldOfResearch { forcode = dataCollectionFieldOfResearchId });
         }
     }
 }
        private static void PopulateUsers(SqlConnection conn, DataCollection dataCollection)
        {
            var cmd = new SqlCommand(string.Format(ConstSqlGetParties, dataCollection.Id), conn);

            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    var userId = reader.GetStringValue("UserId");
                    var fullName = reader.GetStringValue("FullName");
                    var email = reader.GetStringValue("Email");
                    var organisation = reader.GetStringValue("Organisation");
                    var relationship = reader.GetEnumValue<DataCollectionRelationshipType>("Relationship");
                    dataCollection.Parties.Add(new DataCollectionParty
                                                    {
                                                        UserId = userId,
                                                        Email = email,
                                                        FullName = fullName,
                                                        Organisation = organisation,
                                                        Relationship = relationship
                                                    });

                }
            }
        }
        private static void PopulateSeoCodes(SqlConnection conn, DataCollection dataCollection)
        {
            var cmd = new SqlCommand(string.Format(ConstSqlGetSeo, dataCollection.Id), conn);

            using (var sqlReader = cmd.ExecuteReader())
            {
                while (sqlReader.Read())
                {
                    var socioEconomicObjectiveId = sqlReader.GetStringValue("SocioEconomicObjectiveId");
                    dataCollection.SocioEconomicObjectives.Add(new DataCollectionSocioEconomicObjective { seocode = socioEconomicObjectiveId });
                }
            }

        }
        /// <summary>
        /// Writes the specified Data Collection to the Vivo database.
        /// </summary>
        /// <param name="dataCollection">The data collection.</param>
        public void Save(DataCollection dataCollection)
        {
			// TODO: Implement this, save somewhere you can push data out to ANDS from
        }