public ActionResult Delete(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Uzytkownicy        Uzytkownicy = new Uzytkownicy();
            List <Uzytkownicy> Lista       = new List <Uzytkownicy>();

            using (ISession session = NhibernateSession.OpenSession())
            {
                //  List<TypUzytkownika> jakas = session.Query<TypUzytkownika>().ToList();
                //   Uzytkownicy.ListaDostepnych = new List<System.Web.Mvc.SelectListItem>();
                //   for (int i = 0; i < jakas.Count(); i++)
                //   {
                //        SelectListItem Item = new SelectListItem();
                //        Item.Text = jakas[i].nazwa;
                //        Item.Value = jakas[i].id.ToString();
                //         Uzytkownicy.ListaDostepnych.Add(Item);
                //     }
                Uzytkownicy = session.Query <Uzytkownicy>().Where(b => b.id == id).FirstOrDefault();
                using (ITransaction Transaction = session.BeginTransaction())
                {
                    session.Delete(Uzytkownicy);
                    Transaction.Commit();
                }
                Lista = session.Query <Uzytkownicy>().ToList();
            }
            //ViewBag.SubmitAction = "Confirm delete";
            return(View("Index"));
        }
        public ActionResult Edit(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Klasy klasy = new Klasy();

            using (ISession session = NhibernateSession.OpenSession())
            {
                List <Uzytkownicy> jakas = session.Query <Uzytkownicy>().Where(c => c.typu.id == 3).ToList();
                WirtualnyDziennik.Models.Przedmioty.ListaDostepnychNauczycieli = new List <System.Web.Mvc.SelectListItem>();
                for (int i = 0; i < jakas.Count(); i++)
                {
                    SelectListItem Item = new SelectListItem();
                    Item.Text  = jakas[i].nazwa;
                    Item.Value = jakas[i].id.ToString();
                    Przedmioty.ListaDostepnychNauczycieli.Add(Item);
                }
                klasy = session.Query <Klasy>().Where(b => b.id == id).FirstOrDefault();
            }

            ViewBag.SubmitAction = "Save";
            return(View(klasy));
        }
Example #3
0
 public ActionResult Index(int iducznia, int planlekcjiid, DziennikUcznia model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             model.KlasaUczen = session.Query <KlasaUczen>().Where(b => b.Uzytkownik.id == iducznia).First();
             model.PlanLekcji = (PlanLekcji)session.Load("PlanLekcji", planlekcjiid);
             // model.PlanLekcji = session.Query<PlanLekcji>().Where(c => c.planlekcji_id == planlekcjiid).First();
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(model);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index", new { iducznia = iducznia, planlekcjiid = planlekcjiid }));
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message + "##ZRODLO##" + e.Source + "##DALEJ##" + e.InnerException;
         return(View());
     }
 }
        public ActionResult Add(KlasaUczen model)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            KlasaUczen ku = new KlasaUczen();


            try
            {
                using (ISession session = NhibernateSession.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(model);
                        transaction.Commit();
                    }
                }
                return(RedirectToAction("IndexAdmin"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
        public ActionResult EditStudents(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Klasy klasy = new Klasy();

            using (ISession session = NhibernateSession.OpenSession())
            {
                List <KlasaUczen>  klasauczen = session.Query <KlasaUczen>().Where(b => b.Klasa.id == id).ToList();
                IList <Object[]>   s          = session.CreateSQLQuery("select  u.* from uzytkownicy u,klasauczen where u.id=klasauczen.uzytkownik_id and klasauczen.klasa_id=" + id).List <Object[]>();
                List <Uzytkownicy> jakas      = session.Query <Uzytkownicy>().Where(c => c.typu.id == 3).ToList();
                WirtualnyDziennik.Models.Przedmioty.ListaDostepnychNauczycieli = new List <System.Web.Mvc.SelectListItem>();
                for (int i = 0; i < s.Count(); i++)
                {
                    SelectListItem Item = new SelectListItem();
                    Item.Text  = s[i][1].ToString();
                    Item.Value = s[i][0].ToString();
                    Przedmioty.ListaDostepnychNauczycieli.Add(Item);
                }
                klasy = session.Query <Klasy>().Where(b => b.id == id).FirstOrDefault();
            }
            ViewData["klasa"]    = id;
            ViewBag.SubmitAction = "Save";
            return(View(klasy));
        }
 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());
     }
 }
        public ActionResult Index(int id, int przedmiotid)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            List <Klasy>    klasy = new List <Klasy>();
            IList <Decimal> Lista;

            ViewData["przedmiotid"] = przedmiotid;
            using (ISession session = NhibernateSession.OpenSession())
            {
                var s = session.CreateSQLQuery("select k.id from planlekcji pl,przedmioty p,klasy k where pl.planlekcji_id=p.id and k.id=pl.klasa_id and p.id=" + id);

                Lista = s.List <Decimal>();
                for (int i = 0; i < Lista.Count(); i++)
                {
                    Klasy k = new Klasy();

                    k = session.Get <Klasy>(Convert.ToInt32(Lista.ElementAt(i)));
                    klasy.Add(k);
                }
            }

            return(View(klasy));
        }
Example #8
0
        public ActionResult Create(Document document, IEnumerable <HttpPostedFileBase> fileupload)
        {
            string path = String.Empty;

            document.authorId = long.Parse(Session["id"].ToString());

            using (ISession session = NhibernateSession.OpenSession())
            {
                foreach (var file in fileupload)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        var extention = System.IO.Path.GetExtension(file.FileName);
                        path = System.IO.Path.Combine(Server.MapPath("~/Files/"), document.name + extention);
                        file.SaveAs(path);
                        var saveQuery = session.GetNamedQuery("FileSaveProcedure");
                        saveQuery.SetParameter("Name", document.name)
                        .SetParameter("authorId", document.authorId)
                        .SetParameter("changedate", document.changeDate)
                        .SetParameter("BinaryFile", path).ExecuteUpdate();

                        return(RedirectToAction("IndexAll"));
                    }
                    return(View("Create"));
                }
            }
            return(View("Create"));
        }
        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());
            }
        }
Example #10
0
 public ActionResult Create(Tresc model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             model.TypTresci = (TypTresci)session.Load("TypTresci", 1);
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(model);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message + "##ZRODLO##" + e.Source + "##DALEJ##" + e.InnerException;
         return(View());
     }
 }
Example #11
0
        public ActionResult Delete(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Tresc        tresc = new Tresc();
            List <Tresc> Lista = new List <Tresc>();

            using (ISession session = NhibernateSession.OpenSession())
            {
                /* tresc = session.Query<Tresc>().Where(b => b.id == id).FirstOrDefault();
                 * List<TypTresci> jakas = session.Query<TypTresci>().ToList();
                 * WirtualnyDziennik.Models.TypTresci.ListaDostepnych = new List<System.Web.Mvc.SelectListItem>();
                 * for (int i = 0; i < jakas.Count(); i++)
                 * {
                 *   SelectListItem Item = new SelectListItem();
                 *   Item.Text = jakas[i].nazwa;
                 *   WirtualnyDziennik.Models.TypTresci.ListaDostepnych.Add(Item);
                 * }*/
                tresc = session.Query <Tresc>().Where(b => b.id == id).FirstOrDefault();
                using (ITransaction trans = session.BeginTransaction())
                {
                    session.Delete(tresc);
                    trans.Commit();
                }
                Lista = session.Query <Tresc>().ToList();
            }
            // ViewBag.SubmitAction = "Confirm delete";
            return(RedirectToAction("Index", "Tresc"));
        }
Example #12
0
 public ActionResult Edit(int id, Tresc model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             Tresc tresc = session.Get <Tresc>(id);
             tresc.tytul     = model.tytul;
             tresc.tresc     = model.tresc;
             tresc.TypTresci = model.TypTresci;
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.SaveOrUpdate(tresc);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Edit(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Uzytkownicy Uzytkownicy = new Uzytkownicy();

            using (ISession session = NhibernateSession.OpenSession())
            {
                List <TypUzytkownika> jakas = session.Query <TypUzytkownika>().ToList();
                Uzytkownicy.ListaDostepnych = new List <System.Web.Mvc.SelectListItem>();
                for (int i = 0; i < jakas.Count(); i++)
                {
                    SelectListItem Item = new SelectListItem();
                    Item.Text  = jakas[i].nazwa;
                    Item.Value = jakas[i].id.ToString();
                    Uzytkownicy.ListaDostepnych.Add(Item);
                }
                Uzytkownicy = session.Query <Uzytkownicy>().Where(b => b.id == id).FirstOrDefault();
            }

            ViewBag.SubmitAction = "Save";
            return(View(Uzytkownicy));
        }
Example #14
0
 public ActionResult Login(string haslo, string login)
 {
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             Uzytkownicy U = session.Query <Uzytkownicy>().Where(b => b.nazwa == login).FirstOrDefault();
             if (U.haslo == haslo)
             {
                 UserProfileSessionData UserLogged = new UserProfileSessionData
                 {
                     Name         = U.nazwa,
                     UserId       = U.id,
                     EmailAddress = U.email,
                     Typ          = U.typu.nazwa
                 };
                 this.Session.Add("UserProfile", UserLogged);
                 // this.Session["User"] = UserLogged;
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception e)
     {
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }
Example #15
0
 public ActionResult Message(Tresc model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             UserProfileSessionData uspd = this.Session["UserProfile"] as UserProfileSessionData;
             model.OD        = uspd.Name;
             model.TypTresci = (TypTresci)session.Load("TypTresci", 2);
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(model);
                 transaction.Commit();
             }
         }
         return(View());
     }
     catch (Exception e)
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, Przedmioty model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             Przedmioty Przedmioty = session.Get <Przedmioty>(id);
             Przedmioty.nazwa = model.nazwa;
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.SaveOrUpdate(Przedmioty);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("IndexAdmin"));
     }
     catch
     {
         return(View());
     }
 }
Example #17
0
        // GET: Grade
        public ActionResult Index(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            UserProfileSessionData upsd = Session["UserProfile"] as UserProfileSessionData;
            IList <Object[]>       lista;

            WirtualnyDziennik.Models.Przedmioty.ListaDostepnych = new List <SelectListItem>();

            IQuery s = null;

            using (ISession session = NhibernateSession.OpenSession())
            {
                //Odbiorca = session.Query<Uzytkownicy>().Where(b => b.id == id).FirstOrDefault();
                if (upsd.Typ == "UCZEN")
                {
                    s = session.CreateSQLQuery("select dziennikucznia.ocena,typoceny.nazwa,przedmioty.nazwa as PRZEDMIOT, TO_CHAR(dziennikucznia.data,'DD/MM/YYYY') as DATA from typoceny, uzytkownicy, klasauczen, dziennikucznia, planlekcji, przedmioty where dziennikucznia.ocena!=0 and uzytkownicy.id =" + id + " and uzytkownicy.id = klasauczen.uzytkownik_id and klasauczen.klasauczen_id = dziennikucznia.klasauczen_id and typoceny.id=dziennikucznia.typoceny_id and dziennikucznia.planlekcji_id = planlekcji.planlekcji_id and planlekcji.przedmiot_id = przedmioty.id");
                }
                if (upsd.Typ == "RODZIC")
                {
                    s = session.CreateSQLQuery("select uzytkownicy.imie as Imie ,uzytkownicy.nazwisko as Nazwisko ,dziennikucznia.ocena,typoceny.nazwa,przedmioty.nazwa as PRZEDMIOT, TO_CHAR(dziennikucznia.data,'DD/MM/YYYY') as DATA from typoceny,uzytkownicy, klasauczen, dziennikucznia, planlekcji, przedmioty where dziennikucznia.ocena!=0 and uzytkownicy.id in (SELECT u.id FROM uzytkownicy u WHERE EXISTS(SELECT NULL FROM rodzicuczen ru WHERE u.id = ru.uczen_id AND ru.rodzic_id =" + id + ")) and uzytkownicy.id = klasauczen.uzytkownik_id and typoceny.id=dziennikucznia.typoceny_id and klasauczen.klasauczen_id = dziennikucznia.klasauczen_id and dziennikucznia.planlekcji_id = planlekcji.planlekcji_id and planlekcji.przedmiot_id = przedmioty.id");
                }

                lista = s.List <Object[]>();
            }
            return(View(lista));
        }
Example #18
0
        //public ActionResult Delete(int id)
        // {
        //   return View();
        //}
        //[HttpPost]
        public ActionResult DeleteStudent(int id, FormCollection collection)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            int id2;

            try
            {
                using (ISession session = NhibernateSession.OpenSession())
                {
                    //ISQLQuery s = session.CreateSQLQuery("select ku.klasa_id from klasauczen ku where ku.uzytkownik_id=" + id);
                    KlasaUczen ku = session.Query <KlasaUczen>().Where(b => b.Uzytkownik.id == id).First();
                    id2 = ku.Klasa.id;
                    KlasaUczen klasaUczen = session.Query <KlasaUczen>().Where(c => c.Uzytkownik.id == id).First();

                    using (ITransaction trans = session.BeginTransaction())
                    {
                        session.Delete(klasaUczen);
                        trans.Commit();
                    }
                }
                return(RedirectToAction("EditStudents", "Klasy", new { id = id2 }));
            }
            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 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());
     }
 }
Example #21
0
        private void SetUpNhibernateSession()
        {
            NhibernateSession nhibernateSession = new NhibernateSession();
            nhibernateSession.BuildSession(Guid.NewGuid(), Properties.Settings.Default.erpConnectionString);

            this.NhibernateSession = nhibernateSession;
        }
Example #22
0
        public ActionResult Edit(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Tresc tresc = new Tresc();

            using (ISession session = NhibernateSession.OpenSession())
            {
                List <TypTresci> jakas = session.Query <TypTresci>().ToList();
                WirtualnyDziennik.Models.TypTresci.ListaDostepnych = new List <System.Web.Mvc.SelectListItem>();
                for (int i = 0; i < jakas.Count(); i++)
                {
                    SelectListItem Item = new SelectListItem();
                    Item.Text  = jakas[i].nazwa;
                    Item.Value = jakas[i].id.ToString();
                    TypTresci.ListaDostepnych.Add(Item);
                }
                tresc = session.Query <Tresc>().Where(b => b.id == id).FirstOrDefault();
            }

            ViewBag.SubmitAction = "Save";
            return(View(tresc));
        }
Example #23
0
 public async Task <List <UserDTO> > GetAllBy(Expression <Func <UserDTO, bool> > condition)
 {
     using (ISession _context = NhibernateSession.OpenSession())
     {
         return(await _context.Query <User>().ProjectTo <UserDTO>().Where(condition).ToListAsync());
     }
 }
Example #24
0
        // GET: Grade
        public ActionResult Index(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            UserProfileSessionData upsd = Session["UserProfile"] as UserProfileSessionData;
            IList <Object[]>       lista;
            IQuery s = null;

            using (ISession session = NhibernateSession.OpenSession())
            {
                //Odbiorca = session.Query<Uzytkownicy>().Where(b => b.id == id).FirstOrDefault();
                if (upsd.Typ == "UCZEN")
                {
                    s = session.CreateSQLQuery("select dziennikucznia.obecnosc,przedmioty.nazwa as PRZEDMIOT, TO_CHAR(dziennikucznia.data,'DD/MM/YYYY') as DATA from uzytkownicy, klasauczen, dziennikucznia, planlekcji, przedmioty where uzytkownicy.id =" + id + " and uzytkownicy.id = klasauczen.uzytkownik_id and klasauczen.klasauczen_id = dziennikucznia.klasauczen_id and dziennikucznia.planlekcji_id = planlekcji.planlekcji_id and planlekcji.przedmiot_id = przedmioty.id");
                }
                if (upsd.Typ == "RODZIC")
                {
                    s = session.CreateSQLQuery("select uzytkownicy.imie as Imie ,uzytkownicy.nazwisko as Nazwisko ,dziennikucznia.obecnosc,przedmioty.nazwa as PRZEDMIOT, TO_CHAR(dziennikucznia.data,'DD/MM/YYYY') as DATA from uzytkownicy, klasauczen, dziennikucznia, planlekcji, przedmioty where uzytkownicy.id in (SELECT u.id FROM uzytkownicy u WHERE EXISTS(SELECT NULL FROM rodzicuczen ru WHERE u.id = ru.uczen_id AND ru.rodzic_id = " + id + ")) and uzytkownicy.id = klasauczen.uzytkownik_id and klasauczen.klasauczen_id = dziennikucznia.klasauczen_id and dziennikucznia.planlekcji_id = planlekcji.planlekcji_id and planlekcji.przedmiot_id = przedmioty.id");
                }

                /*lista =session.CreateSQLQuery("select uzytkownicy.nazwa as UCZEN ,dziennikucznia.ocena,przedmioty.nazwa as PRZEDMIOT,dziennikucznia.data as DATA from KlasaUczen, Klasy, planlekcji, przedmioty, dziennikucznia, uzytkownicy where uzytkownicy.id = klasauczen.uzytkownik_id and klasauczen.klasa_id = klasy.id and klasy.id = planlekcji.klasa_id  and planlekcji.planlekcji_id = dziennikucznia.planlekcji_id and dziennikucznia.klasauczen_id = klasauczen.klasauczen_id")
                 *   .AddScalar("UCZEN",NHibernateUtil.String)
                 *   .AddScalar("OCENA",NHibernateUtil.Double)
                 *   .AddScalar("PRZEDMIOT",NHibernateUtil.String)
                 *   .AddScalar("DATA",NHibernateUtil.DateTime).List<Object[]>();*/
                lista = s.List <Object[]>();
            }
            return(View(lista));
        }
Example #25
0
 public async Task <UserDTO> GetBy(Expression <Func <UserDTO, bool> > condition)
 {
     using (ISession _context = NhibernateSession.OpenSession())
     {
         return(await _context.Query <User>().ProjectTo <UserDTO>().FirstOrDefaultAsync(condition));
     }
 }
        public ActionResult Delete(int id, FormCollection collection)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            try
            {
                using (ISession session = NhibernateSession.OpenSession())
                {
                    Przedmioty Przedmioty = session.Get <Przedmioty>(id);

                    using (ITransaction trans = session.BeginTransaction())
                    {
                        session.Delete(Przedmioty);
                        trans.Commit();
                    }
                }
                return(RedirectToAction("IndexAdmin"));
            }
            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())
                {
                    TypTresci TTresc = session.Get <TypTresci>(id);

                    using (ITransaction trans = session.BeginTransaction())
                    {
                        session.Delete(TTresc);
                        trans.Commit();
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message + "##ZRODLO##" + e.Source + "##DALEJ##" + e.InnerException;
                return(RedirectToAction("Index"));
            }
        }
Example #28
0
        private void SetUpNhibernateSession()
        {
            NhibernateSession nhibernateSession = new NhibernateSession();

            nhibernateSession.BuildSession(Guid.NewGuid(), Properties.Settings.Default.erpConnectionString);

            this.NhibernateSession = nhibernateSession;
        }
Example #29
0
 public void PostUpdatemovie(Movie movie)
 {
     using (ISession session = NhibernateSession.OpenSession())
     {
         session.Update(movie);
         session.Flush();
     }
 }
Example #30
0
 public bool CheckID(Employees staffId)
 {
     using (ISession session = NhibernateSession.OpenSession())
     {
         bool exist = session.Query <Employees>().Any(x => x.ID == staffId.ID);
         return(exist);
     }
 }
        internal DBSession(IImportContext msi)
        {
            if (msi == null)
                throw new ArgumentNullException("session can not be null IDBSession CreateorGetCurrentSession");

            _NHS = new NhibernateSession(msi, this);
            NHSession = msi.Session.GetNHibernateFactory().OpenSession(_NHS);
            
        }
Example #32
0
        public async Task <UserDTO> GetById(int id)
        {
            using (ISession _context = NhibernateSession.OpenSession())
            {
                var entity = await _context.Query <User>().Where(u => u.Id == id).FirstOrDefaultAsync();

                return(Mapper.Map <User, UserDTO>(entity));
            }
        }