コード例 #1
0
        public JsonResult CreateNote([FromBody] NewNote note)
        {
            List <Dictionary <string, object> > newNote = _dbConnector.Query($"INSERT INTO notes (title, content, top_pos, left_pos, created_at, updated_at) VALUES ('{note.title.Replace("'", "''")}', ' ', {10}, {10}, now(), now()); SELECT id, title, content, top_pos, left_pos FROM notes WHERE id=LAST_INSERT_ID();");

            Dictionary <string, object> selectedNote = newNote[0];

            return(Json(selectedNote));
        }
コード例 #2
0
        public JsonResult DeleteNote([FromBody] NewNote note)
        {
            string query = $"DELETE FROM notes WHERE id='{note.id}'";

            _dbConnector.Query(query);

            object success = new {
                success = true
            };

            return(Json(success));
        }
コード例 #3
0
        public JsonResult UpdateNote([FromBody] NewNote note)
        {
            string query = $"UPDATE notes SET title='{note.title.Replace("'", "''")}', content='{note.content.Replace("'", "''")}', top_pos='{note.top_pos}', left_pos='{note.left_pos}', updated_at=now() WHERE id='{note.id}'";

            _dbConnector.Query(query);

            object success = new {
                success = true
            };

            return(Json(success));
        }