Пример #1
0
        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());
            }
        }
Пример #2
0
        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();
             * }*/
        }
Пример #3
0
 //Delete : Personne
 public ActionResult Delete(String id)
 {
     using (ISession session = NhibernateSession.OpenSession())
     {
         var personne = session.Get <person>(id);
         return(View(personne));
     }
 }
Пример #4
0
        // Read: Personne
        public ActionResult Index()
        {
            using (ISession session = NhibernateSession.OpenSession())
            {
                var personnes = session.Query <person>().ToList();
                return(View(personnes));
            }

            //  var personne = Session["user"];
        }
Пример #5
0
 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());
     }
 }
Пример #6
0
        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());
            }
        }