public ActionResult DeleteByEmployee(decimal id) { try { //EmployeeDocument.DeleteByEmployee(id); List <EmployeeDocument> list = EmployeeDocument.FindByEmployee(id); foreach (EmployeeDocument obj in list) { EmployeeDocument.Delete(obj.EmpDoc_Id); string oldfileName = Server.MapPath(obj.EmpDoc_File); if (System.IO.File.Exists(oldfileName)) { System.IO.File.Delete(oldfileName); } } ViewBag.Message = "Employee Document(s) Deleted Successfully"; return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public ActionResult List(decimal id) { ViewData["EmpId"] = id; return(View(EmployeeDocument.FindByEmployee(id))); }