Example #1
0
        // PUT: api/Student
        //BODY: {"name" : "Danny","marks" : 40,"favoritesubject" : "Geography"}
        //Update a specific node
        public HttpResponseMessage Put([FromBody] Student std)
        {
            service = new Neo4jStudentApiService(ServerUri, Username, Password);
            var result = service.UpdateStudent(std);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Example #2
0
        // GET: api/Student?name=Alice
        //Get specific node
        public HttpResponseMessage Get(string name)
        {
            service = new Neo4jStudentApiService(ServerUri, Username, Password);
            var Student = service.GetStudent(name);

            return(Request.CreateResponse(HttpStatusCode.OK, Student));
        }
Example #3
0
        // GET: api/Student
        //Get all the nodes
        public HttpResponseMessage Get()
        {
            service = new Neo4jStudentApiService(ServerUri, Username, Password);
            var StudentList = service.GetAllStudents();

            return(Request.CreateResponse(HttpStatusCode.OK, StudentList));
        }
Example #4
0
        // DELETE: api/Student?name=Danny
        //Detach all relationship and then delete the node
        public HttpResponseMessage Delete(string name)
        {
            service = new Neo4jStudentApiService(ServerUri, Username, Password);
            var result = service.DeleteStudent(name);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Deleted"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Failed"));
            }
        }
Example #5
0
        // POST: api/Student
        //BODY: {"name" : "Danny","marks" : 75,"favoritesubject" : "Science"}
        //Create a node
        public HttpResponseMessage Post([FromBody] Student std)
        {
            service = new Neo4jStudentApiService(ServerUri, Username, Password);
            var result = service.CreateStudent(std);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.Created, "Inserted"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Failed"));
            }
        }