Пример #1
0
        public static async Task <ResultSet <dynamic> > UpdatePlaylistVertexQuery(string playlistId, PlaylistVertex p)
        {
            StringBuilder queryString = new StringBuilder(GetVertex(playlistId));

            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, "playlist", playlistId, p).ConfigureAwait(false));
            }

            return(await DatabaseConnection.Instance.ExecuteQuery(queryString.ToString()));
        }
Пример #2
0
        public static async Task <ResultSet <dynamic> > CreatePlaylistVertexQuery(string email, PlaylistVertex p, string seed)
        {
            string playlistId = Guid.NewGuid().ToString();

            email = email.ToLowerInvariant();

            StringBuilder queryString = new StringBuilder(CreateVertex("playlist", playlistId));

            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, "playlist", playlistId, 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()));
        }