Beispiel #1
0
        public async Task <int> Put(int id, [FromBody] ClientNode dto)
        {
            _log.Information("change node with {id}", id);
            using (var dbGraphContext = new DbGraphContext(_options))
            {
                var node = dbGraphContext.Nodes.First(n => n.Id == id);
                node.Title     = dto.Title;
                node.Latitude  = dto.Coors.Latitude;
                node.Longitude = dto.Coors.Longitude;
                await dbGraphContext.SaveChangesAsync();

                return(200);
            }
        }
Beispiel #2
0
        public async Task <int> Post([FromBody] CoordinatesArg arg)
        {
            _log.Information("create node {coordinates}", arg);
            using (var dbGraphContext = new DbGraphContext(_options))
            {
                var node = new DbNode {
                    Latitude = arg.Latitude, Longitude = arg.Longitude
                };
                dbGraphContext.Add(node);
                await dbGraphContext.SaveChangesAsync();

                return(node.Id);
            }
        }
Beispiel #3
0
        public async Task <IHttpActionResult> Put(int id, [FromBody] NodeArg arg)
        {
            _log.Information("change node with {id}", id);
            using (var db = new DbGraphContext(_options))
            {
                var node = await db.Nodes.SingleOrDefaultAsync(n => n.Id == id);

                if (node == null)
                {
                    return(BadRequest("node is not found"));
                }
                node.Title     = arg.Title;
                node.Latitude  = arg.Coordinates.Latitude;
                node.Longitude = arg.Coordinates.Longitude;
                await db.SaveChangesAsync();
            }
            return(Ok());
        }