Пример #1
0
 public Person GetPersonById(int Id)
 {
     Person person = new Person();
     using (ISession session = NHibernateHelper.OpenSession())
     {
         person = session.Get<Person>(Id);
     }
     return person;
 }
Пример #2
0
 public void UpdatePerson(Person person)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         using (ITransaction tran = session.BeginTransaction())
         {
             session.Update(person);
             tran.Commit();
         }
     }
 }
Пример #3
0
 public ActionResult Create(Person person)
 {
     try
     {
         objDs.CreatePerson(person);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Пример #4
0
 public int CreatePerson(Person person)
 {
     int PersonId = 0;
     using (ISession session = NHibernateHelper.OpenSession())
     {
         //Perform transaction
         using (ITransaction tran = session.BeginTransaction())
         {
             session.Save(person);
             tran.Commit();
         }
     }
     return PersonId;
 }
Пример #5
0
 public ActionResult Edit(int id, Person person)
 {
     try
     {
         objDs.UpdatePerson(person);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Пример #6
0
 //
 // GET: /Person/Create
 public ActionResult Create()
 {
     var person = new Person();
     return View(person);
 }