the controller code looks like
public class EmployeeController : Controller
{
public enum EmployeeType
{
RecruitmentOffice,
ResearchI
This is also pretty cool:
[Flags]
public enum PersonRole { User, Student, Instructor };
then from your razor view:
and in your javascript:
function onclickDeleteRole(role) {
var personId = $('#SelectedPersonId').val();
$.ajax({
url: window.getUrl('Person/DeletePersonRole'),
type: 'POST',
dataType: 'json',
data: {
personId: personId,
roles: role
},
success: function (json) {
alert('success!')
},
error: function (jqXHR, status, error) {
alert('error')
}
});
}
and your controller action:
public JsonResult DeletePersonRole(int personId, PersonRoleEnum roles)
{
// do business logic here...
// roles will now have value PersonRoleEnum.User|PersonRoleEnum.Student
// and you can use roles.HasFlag(PersonRoleEnum.User) to check if that flag is set
return Json(new {Result = "OK"});
}
EDIT: for readability, you can always use strings in javascript, and MVC will parse those for you, e.g.
$.ajax({
url: window.getUrl('Person/DeletePersonRole'),
type: 'POST',
dataType: 'json',
data: {
personId: 1,
roles: 'Student'
},
success: function (json) {
alert('success!')
},
error: function (jqXHR, status, error) {
alert('error')
}
});