public ActionResult Edit(Telefone obj) { using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { session.Merge(obj); transaction.Commit(); ViewData[Constantes.VD_MSG_SUCESSO] = Constantes.MSG_SUCESSO_REGISTRO_ATUALIZADO; } catch (PropertyValueException) { ViewData[Constantes.VD_MSG_ERRO] = Constantes.MSG_ERRO_REGISTRO_ATUALIZADO; transaction.Rollback(); } } } return View("Edit", obj); }
public ActionResult Edit(int id) { Telefone obj = new Telefone(); if (id > 0) { obj = NHibernateHelper.OpenSession().CreateCriteria<Telefone>() .Add(Restrictions.Eq(Projections.Property(Telefone.ID), id)) .UniqueResult<Telefone>(); } return View("Edit", obj); }