delete function is not working in my application
controller code
ExerciseEntities1 Db = new ExerciseEntities1();
// GET: /Employee/
public ActionResult Index()
{
return View("Index", "", GetEmployee());
}
public JsonResult GetEmployee()
{
var emp = Db.Employees.ToList();
return Json(emp, JsonRequestBehavior.AllowGet);
}
//
//
[HttpDelete]
public JsonResult DeleteEmployee(int Id)
{
Employee emp = Db.Employees.Find(Id);
Db.Employees.Remove(emp);
Db.SaveChanges();
return Json(emp, JsonRequestBehavior.AllowGet);
}
//
}
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script>
<script>
var angular = angular.module('mvcapp', []);
angular.controller('DemoController', function ($scope, $http) {
GetAllData();
$scope.isDisabledupdate = true;
//Get All Employee
function GetAllData() {
$http.get('/Employee/GetEmployee').success(function (data) {
$scope.employees = data;
});
};
//
$scope.deleteemp = function (empModel) {
debugger
varIsConf = confirm('Want to delete ' + empModel.FirstName + '. Are you sure?');
if (varIsConf) {
$http.delete('/Employee/DeleteEmployee/' + empModel.Id).success(function () {
$scope.errors = [];
GetAllData();
alert(empModel.Name + " Deleted Successfully!!!");
}).error(function () {
alert(data.errors);
});
}
};
});
</script>
when i try to delete the record of id
following error showing
http://localhost:8112/Employee/DeleteEmployee/10 not foundcode in controller is not firing
How to solve this
Regards
Baiju