Add post, fix delete forum, fix null pointer exceptions, min max limist

on database strings
This commit is contained in:
2017-06-12 17:22:58 +03:00
parent 1249950059
commit 430d02f59e
10 changed files with 148 additions and 22 deletions

View File

@@ -11,6 +11,10 @@
<br/>
<button onclick="searchForum('author', prompt('Author: ', 'veeb'))">SearchForumAuthor</button>
<button onclick="searchForum('title', prompt('Title: ', 'test'))">SearchForumTitle</button>
<button onclick="searchForum('authorPosts', prompt('Author: ', 'test'))">SearchAuthorPosts</button>
<br/>
<button onclick="addPost(prompt('ForumId', '1'), 'Best title', prompt('Body', 'Lahe post'))">AddPost</button>
<code><pre id="output"></pre></code>
@@ -83,4 +87,22 @@
out.innerText = JSON.stringify(data, null, 2);
});
}
function addPost(id, title, body) {
var dto = {
Author: "Ajax",
Body: body,
Title: title
}
fetch("/api/foorum/"+id,
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(dto)
}).then(resp => getForum(id));
}
getForums();
</script>