コード例 #1
0
        public async Task <ActionResult <NetworkGraph> > Post([FromBody] NodeLinks NodeLinks)
        {
            if (NodeLinks.nodes != null)
            {
                JsonSerializerOptions options = new JsonSerializerOptions();
                options.WriteIndented = true;
                var newNetworkGraph = new NetworkGraph {
                    schema  = JsonSerializer.Serialize(NodeLinks, options),
                    shortId = Guid.NewGuid().ToString().Substring(0, 8)
                };
                await _db.NetworkGraph.AddAsync(newNetworkGraph);

                await _db.SaveChangesAsync();

                return(CreatedAtAction(nameof(Get), new NetworkGraph {
                    Id = newNetworkGraph.Id,
                    shortId = newNetworkGraph.shortId,
                    schema = newNetworkGraph.schema,
                    updateCount = newNetworkGraph.updateCount
                }));
            }
            return(BadRequest("Node Object was null"));
        }