public ActionResult Create(String nazwa)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         TypUzytkownika TUzytkownik = new TypUzytkownika();
         TUzytkownik.nazwa = nazwa;
         using (ISession session = NhibernateSession.OpenSession())
         {
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(TUzytkownik);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View());
     }
 }
        public ActionResult Delete(int id, FormCollection collection)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            try
            {
                using (ISession session = NhibernateSession.OpenSession())
                {
                    TypUzytkownika TUzytkownik = session.Get <TypUzytkownika>(id);

                    using (ITransaction trans = session.BeginTransaction())
                    {
                        session.Delete(TUzytkownik);
                        trans.Commit();
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
 public ActionResult Edit(int id, FormCollection collection)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         TypUzytkownika TUzytkownik = new TypUzytkownika();
         TUzytkownik.id    = id;
         TUzytkownik.nazwa = collection["Nazwa"].ToString();
         using (ISession session = NhibernateSession.OpenSession())
         {
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.SaveOrUpdate(TUzytkownik);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Details(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            TypUzytkownika TUzytkownik = new TypUzytkownika();

            using (ISession session = NhibernateSession.OpenSession())
            {
                TUzytkownik = session.Query <TypUzytkownika>().Where(b => b.id == id).FirstOrDefault();
            }

            return(View(TUzytkownik));
        }
        public ActionResult Delete(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            TypUzytkownika TUzytkownik = new TypUzytkownika();

            using (ISession session = NhibernateSession.OpenSession())
            {
                TUzytkownik = session.Query <TypUzytkownika>().Where(b => b.id == id).FirstOrDefault();
            }
            ViewBag.SubmitAction = "Confirm delete";
            return(View("Edit", TUzytkownik));
        }