I needs to get a List<users> in Json format
I have tried the following
My KnockoutJS as
var self = this;
self.http = new httpWrapper();
self.GetAllUserForApproval = function () {
self.http.post('/Lending/Account/GetAllUsersForApproval')
.done(function (data) {
alert(data.Payload);
});
};
My Controller As
[HttpPost]
public JsonResult GetAllUsersForApproval()
{
return Json(AccountRepo.GetUserForApproval());
}
The AccountRepo.GetUserForApproval() definition is like
public List<User> GetUserForApproval()
{
return Context.Users
.Where(x => x.IsConfirmationPending).ToList<User>() ?? new List<User>();
}
The Problem is when executing the self.http.post('/Lending/Account/GetAllUsersForApproval')
it shows the error as
Failed to load resource: the server responded with a status of 500 (Internal Server Error),
But if i change the AccountRepo.GetUserForApproval() definition to
public User GetUserForApproval()
{
return Context.Users
.Where(x => x.IsConfirmationPending).FirstOrDefault() ?? new User();
}
it works fine and i got the result in js success function ,
But i want List of users
Plz help me..