コード例 #1
0
 public ActionResult Create(int klasaid, int przedmiotid)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             PlanLekcji pl = new PlanLekcji();
             pl.Klasa     = (Klasy)session.Load("Klasy", klasaid);
             pl.Przedmiot = (Przedmioty)session.Load("Przedmioty", przedmiotid);
             pl.data      = DateTime.Now.Date;
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(pl);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("ListaLekcji", "Classes", new { id = klasaid, przedmiotid = przedmiotid }));
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message + "##ZRODLO##" + e.Source + "##DALEJ##" + e.InnerException;
         return(View());
     }
 }
コード例 #2
0
        public ActionResult CreateAdmin(int id, PlanLekcji model)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            PlanLekcji pl = new PlanLekcji();

            try
            {
                using (ISession session = NhibernateSession.OpenSession())
                {
                    model.data = DateTime.Now.Date;

                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(model);
                        transaction.Commit();
                    }
                }
                return(RedirectToAction("Index", new { id = id }));
            }
            catch (Exception e)
            {
                return(View());
            }
        }