I have this action in my web api controller and using to return departmentId.
public IHttpActionResult GetDepId()
{
var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
string name = User.Identity.Name;
var depId = manager.Users.Where(d => d.Email == name).Select(c => c.DepartmentId).FirstOrDefault();
return Ok(depId);
}
But how to get this singel ID in Jquery ...? I'am trying like this but I get error "undefined"
function GetDept() {
$.ajax({
url: '/Api/userdp', // userdp is my controller
type: 'GET',
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
result; // failed even this result.Email;
},
error: {
}
});
}
Thank you in advance!