[HttpPost]
public ActionResult Delete(ContactsViewModel model)
{
var contact = _contactService.GetContactById(model.Id);
if (contact == null)
return View();
var idArray = new[] { model.Id };
_contactService.RemoveContact(idArray);
return RedirectToAction("Index");
}
this the contact controller
@using (Html.BeginForm())
{
<div>
<h4 class="center">Available Contact(s)</h4><br /><div>
@Html.AntiForgeryToken()
</div>
</div><div class="span12"></div>
<div class=" btn-group">
<input class="btn btn-info " type="submit" value=" Send Message"><input class="btn btn-info " type="submit" value=" Add to Group"><input class="btn btn-info " type="submit" value=" Delete Contacts">
</div>
}
<div class="span11 blog-item ">
<div class="row-fluid">
<div class="span12">
<table class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th></th>
<th><h4 class="center">Contact Name(s)</h4></th>
<th><h4 class="center">Mobile Number(s)</h4></th>
<th><h4 class="center">Actions</h4></th>
</tr>
</thead>
@foreach (var item in Model)
{
<tbody>
<tr>
<td><input type="checkbox" value="@item.Id" name="deleteInputs"></td>
<td>
@Html.DisplayFor(modelItem => item.Name, new { @class = "center" })
</td>
<td>
@Html.DisplayFor(modelItem => item.MobileNumber, new { @class = "center" })
</td>
<td>
<a data-toggle="modal" href="#loginForm">Add To Group</a>
@*@Html.ActionLink("Add to Group", "AddtoGroup", new { }, new { @class = "center", })*@ |
@Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "center" }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
</tbody>
}
</table>
And this is the view that display every contacts in a table...
So please how do i go about selecting multiple contact using the checkbox and delete with the button in my controller and am using Services with Repository