Now can change forum data

This commit is contained in:
2017-06-12 15:46:53 +03:00
parent 44c733b582
commit 3707a8dce2
5 changed files with 35 additions and 4 deletions

View File

@@ -51,8 +51,10 @@ namespace WebApi.Controllers
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
public IHttpActionResult Put(int id, [FromBody]FoorumDTO foorum)
{
foorum.FoorumId = id;
return Ok(_foorumService.Update(foorum));
}
// DELETE api/<controller>/5

View File

@@ -4,6 +4,8 @@
<button onclick="getForum(prompt('ForumId: ', '1'))">GetForum</button>
<button onclick="getForums()">GetAllForums</button>
<button onclick="addForum()">AddForum</button>
<button onclick="changeForumTitle(prompt('ForumId: ', '1'), prompt('ForumTitle: ', 'Muudetud'))">ChangeForumTitle</button>
<br/>
<button onclick="searchForumAuthor(prompt('Author: ', 'veeb'))">SearchForumAuthor</button>
<code><pre id="output"></pre></code>
@@ -45,6 +47,20 @@
});
}
function changeForumTitle(id, title) {
var dto = {
Title: title
}
fetch("/api/foorum/"+id,
{
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(dto)
});
}
function searchForumAuthor(author) {
fetch("/api/search?author="+author).then(resp => {
return resp.json();