Now can change forum data
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user