I need to do the following table with .NET MVC and AJAX:
The idea is a list with users with the option to lock each of them (i am using the standard identity model):
Email | Username | LockoutEnabled
user1@domain.com | User1 | [x]
user2@domain.com | User2 | [0]
user3@domain.com | User3 | [0]
For the moment I successfully update the current status in the view from the db to the checkbox using this approach
<td> @Html.EditorFor(modelItem => user.LockoutEnabled) </td>
What i want to do next is:
1. Update the db on the current checkbox status without reloading the page
2. Show a notification on successful DB update from the view (no reload)
This is the controller returning the status
[Authorize(Roles = "Admin")] public ActionResult LockUser(string id, bool status) { PFMDbContext db = new PFMDbContext(); db.Users.FirstOrDefault(user => user.Id == id).LockoutEnabled = status; db.SaveChanges(); return new HttpStatusCodeResult(HttpStatusCode.OK); }
Aucun commentaire:
Enregistrer un commentaire