public ActionResult EditEmpDetails(int id, EmpModel obj) { try { EmpRepository EmpRepo = new EmpRepository(); EmpRepo.UpdateEmployee(obj); return RedirectToAction("GetAllEmpDetails"); } catch { return View(); } }
// update Employee public void UpdateEmployee(EmpModel objUpdate) { try { connection(); con.Open(); con.Execute("UpdateEmpDetails", objUpdate, commandType: CommandType.StoredProcedure); con.Close(); } catch (Exception) { throw; } }
// Add Employee public void AddEmployee(EmpModel objEmp) { //Additing the employess try { connection(); con.Open(); con.Execute("AddNewEmpDetails", objEmp, commandType: CommandType.StoredProcedure); con.Close(); } catch (Exception ex) { throw ex; } }
public ActionResult AddEmployee(EmpModel Emp) { try { if (ModelState.IsValid) { EmpRepository EmpRepo = new EmpRepository(); EmpRepo.AddEmployee(Emp); ViewBag.Message = "Records added successfully."; } return View(); } catch { return View(); } }