public ActionResult Edit(int id, Employee employee) { try { using (ISession session = NHibernateSession.OpenSession()) { var employeetoUpdate = session.Get<Employee>(id); employeetoUpdate.Designation = employee.Designation; employeetoUpdate.FirstName = employee.FirstName; employeetoUpdate.LastName = employee.LastName; using (ITransaction transaction = session.BeginTransaction()) { session.Save(employeetoUpdate); transaction.Commit(); } } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Employee emplolyee) { try { using (ISession session = NHibernateSession.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(emplolyee); transaction.Commit(); } } return RedirectToAction("Index"); } catch (Exception exception) { return View(); } }