public ActionResult Delete(int id) { var com = new DBComponent(); com.DeleteEmployee(id); return(RedirectToAction("AllEmployees")); }
public ActionResult Delete(string id) { ViewData["Error"] = "";//Initialize it to "" var obj = new DBComponent(); int empid = int.Parse(id); try { obj.DeleteEmployee(empid); } catch (Exception ex) { ViewData["Error"] = ex.Message;//set the error message } return(View("AllEmployees", obj.GetAllEmployees())); //ViewData is another way of sharing data to the View. ViewData is a dictionary object where data is stored as KEY-VALUE pairs... }