i 具有fol光指数,显示物体清单和删除Ajax。 行动联系:
<legend>@Model.Where(d => d.VisitStatu.Description.ToUpper().Equals("ASSINGED")).Count() @ViewBag.subtitle</legend>
<table>
<tr>
<th>Patient Full Name </th>
<th>Created BY</th>
<th></th>
</tr>
@foreach (var item in Model.Where(d => d.VisitStatu.Description.ToUpper().Equals("ASSINGED")))
{
<tr id = @item.VisitID>
<td>@Html.DisplayFor(modelItem => item.Patient.FullName)</td>
<td>@Html.DisplayFor(modelItem => item.CreatedBy)</td>
<td>@Ajax.ActionLink("Delete",
"Delete", "Visit",
new { id = item.VisitID },
new AjaxOptions
{
HttpMethod = "Post",
OnSuccess = "deletionconfirmation",
OnFailure = "deletionerror"
}
</td> </tr>
Ajax。 行动联系将称为以下行动方法:
[HttpPost]
public ActionResult Delete(int id)
{ try
{ var v = repository.GetVisit(id);
if (!(v.Editable(User.Identity.Name)))
{return View("NotFound"); }
repository.DeleteVisit(v);
repository.Save();
return Json(new { IsSuccess = "True", id = id, description = v.Date.ToString() }, JsonRequestBehavior.AllowGet);
}
catch (DbUpdateConcurrencyException)
{
return Json(new { IsSuccess = "False" }, JsonRequestBehavior.AllowGet);
}
catch (OptimisticConcurrencyException)
{
return Json(new { IsSuccess = "False" }, JsonRequestBehavior.AllowGet);
}}
But currently if the user clicks on the Delete link and the record was modified by another user then no DbUpdateConcurrencyException
will be raised ,, as i am not passing the timestamp to the delete action method... so how i can include the timestamp values with the Delete ajax.actionlink?
//Hint the object already include a timestamp propert.
BR