Ejemplo n.º 1
0
        public static async Task <ResultSet <dynamic> > CreateSampleVertexQuery(string email, SampleVertex p, string seed)
        {
            string sampleId = Guid.NewGuid().ToString();

            email = email.ToLowerInvariant();

            StringBuilder queryString = new StringBuilder(CreateVertex("sample", sampleId));

            foreach (PropertyInfo prop in p.GetType().GetProperties())
            {
                // Skip null or empty fields
                if (prop.GetValue(p) == null || string.IsNullOrWhiteSpace(prop.GetValue(p).ToString()))
                {
                    throw new ArgumentException($"{prop.Name} must not be empty");
                }

                queryString.Append(await SetField(prop, "sample", sampleId, p).ConfigureAwait(false));
            }

            if (!string.IsNullOrWhiteSpace(seed))
            {
                queryString.Append(AddProperty("seed", seed));
            }

            queryString.Append(CreateEdge("OWNED_BY", email) + EdgeSourceReference());

            return(await DatabaseConnection.Instance.ExecuteQuery(queryString.ToString()));
        }
Ejemplo n.º 2
0
        public static async Task <ResultSet <dynamic> > UpdateSampleVertexQuery(string sampleId, SampleVertex p)
        {
            StringBuilder queryString = new StringBuilder(GetVertex(sampleId));

            foreach (PropertyInfo prop in p.GetType().GetProperties())
            {
                // Skip null or empty fields
                if (prop.GetValue(p) == null || string.IsNullOrWhiteSpace(prop.GetValue(p).ToString()))
                {
                    continue;
                }

                queryString.Append(await SetField(prop, "sample", sampleId, p).ConfigureAwait(false));
            }

            return(await DatabaseConnection.Instance.ExecuteQuery(queryString.ToString()));
        }