Delete Navigation

Actually, we just need to do the same thing with our previous action, Add and Edit. Then, it is done.

public ActionResult Delete(int? id)
{
    if (id == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }

    Entry entry = _entriesRepository.GetEntry((int)id);

    if (entry == null)
    {
        return HttpNotFound();
    }

    return View(entry);
}

Alike Edit Action, we need to declare Delete action after POST request.

[HttpPost]
public ActionResult Delete(int id)
{
    _entriesRepository.DeleteEntry(id);

    return RedirectToAction("Index");
}

results matching ""

    No results matching ""