public ActionResult Delete(int id) { Location location = _locationmanager.Find(x => x.Id == id).FirstOrDefault(); _locationmanager.Remove(location); _locationmanager.SaveChanges(); TempData["Success"] = "Deleted Successfully!"; return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { var location = _locationManager.GetById(id); try { if (_locationManager.Remove(location)) { ViewBag.Msg = "Location deleted Successfully"; } } catch (Exception exception) { ViewBag.Msg = exception.GetType().ToString(); } return(View("Search")); }