I have made this project using this [Template](https://visualstudiogallery.msdn.microsoft.com/48d928e3-9b5c-4faf-b46f-d6baa7d9886c"this text appears when you mouse over").
It is a simple task manager, where you can create, complete, and delete a task.
I got it up and running and added an extra button, by almost completely copying the template author's code.
I following code is an example of his method and my method.
CODE
His way to complete a task:
frontend:
// called by ng-click="complete($index)"
$scope.complete = function(index)
{
$http.post('/api/WS_Todo/CompleteTodoItem/' + $scope.todoList[index].id)
.success(function (data, status, headers, config) {
$scope.getList();
});
}
backend:
[HttpPost]
[Authorize]
async public Task<HttpResponseMessage> CompleteTodoItem(int id)
{
var item = db.todos.Where(t => t.id == id).FirstOrDefault();
if (item != null)
{
item.completed = true;
await db.SaveChangesAsync();
}
return Request.CreateResponse(HttpStatusCode.Accepted);
}
My way to reopen a task:
frontend:
// called by ng-click="reopen($index)"
$scope.reopen = function(index)
{
$http.post('/api/WS_Todo/ReopenTodoItem', +$scope.todoList[index].id)
.success(function (data, status, headers, config) {
$scope.getList();
});
}
backend:
[HttpPost]
[Authorize]
async public Task<HttpResponseMessage> ReopenTodoItem(int id)
{
var item = db.todos.Where(t => t.id == id).FirstOrDefault();
if (item != null)
{
item.completed = false;
await db.SaveChangesAsync();
}
return Request.CreateResponse(HttpStatusCode.Accepted);
}
PROBLEM
His code works as intended.
My code gives me:
POST http://localhost:33651/api/WS_Todo/ReopenTodoItem 404 (Not Found) angularjs:9734
And i can't see how the routing should be a problem when both methods are in the same frontent and backend controller.