public ActionResult Edit(String id, person personne) { try { using (ISession session = NhibernateSession.OpenSession()) { var personnetoUpdate = session.Get <person>(id); personnetoUpdate.Iduser = personne.Iduser; personnetoUpdate.Password = personne.Password; using (ITransaction transaction = session.BeginTransaction()) { session.Save(personnetoUpdate); transaction.Commit(); } } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(person personne) { /* try * {*/ using (ISession session = NhibernateSession.OpenSession()) { var univ = session.Get <University>(personne.University.Name); personne.University = univ; // return Content(univ.Id); // return Content(personne.FirstName+" etudie à "+personne.University.Name); using (ITransaction transaction = session.BeginTransaction()) { session.Save(personne); transaction.Commit(); } } return(RedirectToAction("Index")); /* } * catch (Exception e) * { * return View(); * }*/ }
//Delete : Personne public ActionResult Delete(String id) { using (ISession session = NhibernateSession.OpenSession()) { var personne = session.Get <person>(id); return(View(personne)); } }
// Read: Personne public ActionResult Index() { using (ISession session = NhibernateSession.OpenSession()) { var personnes = session.Query <person>().ToList(); return(View(personnes)); } // var personne = Session["user"]; }
public ActionResult Delete(String id, person personne) { try { using (ISession session = NhibernateSession.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Delete(personne); transaction.Commit(); } } return(RedirectToAction("Index")); } catch (Exception exception) { return(View()); } }
public ActionResult Index(person p) { try { using (ISession session = NhibernateSession.OpenSession()) { var personne = session.Get <person>(p.Iduser); if (!personne.Password.Equals(p.Password)) { throw new NullReferenceException(); } Session["user"] = personne.FirstName; Session.Timeout = 10; return(RedirectToAction("Index", "Personne")); } }catch (Exception e) { return(View()); } }