// // GET: /Company/Edit/5 public ActionResult Edit(Guid id) { NHibernateHelper helper = new NHibernateHelper(@"fluentData.db"); Company company = helper.GetSession().Get<Company>(id); return View(company); helper.CloseSessionFactory(); }
public ActionResult Create(FormCollection collection) { try { NHibernateHelper nhibernateHelper = new NHibernateHelper(@"fluentData.db"); using(ISessionFactory sessionFactory = nhibernateHelper.GetSessionFactory()) { using (ISession session = sessionFactory.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { var company = new Company { OrganizationNumber = collection.GetValue("OrganizationNumber").AttemptedValue, Name = collection.GetValue("Name").AttemptedValue }; session.SaveOrUpdate(company); transaction.Commit(); //collection.Set("Id", company.Id.ToString()); return RedirectToAction("Edit", new { id = company.Id }); } } } } catch { return View(); } }