コード例 #1
0
        public void inserirPizza()
        {
            var provider = new SessionFactoryProvider();
            var sessionProvider = new SessionProvider(provider);
            var sessaoAtual = sessionProvider.GetCurrentSession();

            var pizza = new Pizza{Nome = "Muçarela"};
            sessaoAtual.Save(pizza);

            var ingrediente1 = new Ingrediente {Nome = "Queijo"};
            var ingrediente2 = new Ingrediente {Nome = "Oregano"};
            var ingrediente3 = new Ingrediente {Nome = "Tomate"};

            pizza.AcrescentarIngrediente(ingrediente1);
            pizza.AcrescentarIngrediente(ingrediente2);
            pizza.AcrescentarIngrediente(ingrediente3);

            sessaoAtual.Save(ingrediente1);
            sessaoAtual.Save(ingrediente2);
            sessaoAtual.Save(ingrediente3);
            sessaoAtual.Clear();

            Assert.AreEqual("Muçarela", sessaoAtual.Get<Pizza>(pizza.Id).Nome);

            Assert.AreEqual(3, sessaoAtual.Get<Pizza>(pizza.Id).Ingredientes.Count);
        }
コード例 #2
0
 public void AutoCriarBancoDeDados()
 {
     var sessionFactoryProvider = new SessionFactoryProvider();
     var sessionProvider = new SessionProvider(sessionFactoryProvider);
     sessionProvider.GetCurrentSession();
     sessionFactoryProvider.AutoCriarBancoDeDados();
 }
コード例 #3
0
        public void AutoCriarBancoDeDados()
        {
            var sessionFactoryProvider = new SessionFactoryProvider();
            var sessionProvider        = new SessionProvider(sessionFactoryProvider);

            sessionProvider.GetCurrentSession();
            sessionFactoryProvider.AutoCriarBancoDeDados();
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: william0503/Pizzaria
        public static WindsorContainer InicializarContainer()
        {
            var container = new WindsorContainer();

            container.Register(Component.For<IAdministradorServico>().ImplementedBy<AdministradorServico>());
            container.Register(Component.For<IPizzaDAO>().ImplementedBy<PizzaDAO>());
            container.Register(Component.For<IIngredienteDAO>().ImplementedBy<IngredienteDAO>());
            container.Register(Component.For<IBancoDadosCreator>().ImplementedBy<BancoDadosCreator>());
            var sessionFactory = new SessionFactoryProvider();
            container.Register(Component.For<SessionProvider>().Instance(new SessionProvider(sessionFactory)).LifeStyle.Singleton);
            return container;
        }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: saitodisse/Pizzaria
        private int InsertNewPizza()
        {
            var provider = new SessionFactoryProvider();
            var sessionProvider = new SessionProvider(provider);
            var sessaoAtual = sessionProvider.GetCurrentSession();

            if (Request.Form["Nome"] != null)
            {
                string nome = Request.Form["Nome"].ToString();

                var pizza = new Pizza {Nome = nome};
                sessaoAtual.Save(pizza);

                var ingrediente1 = new Ingrediente { Nome = Request.Form["I1"].ToString() };
                var ingrediente2 = new Ingrediente { Nome = Request.Form["I2"].ToString() };
                var ingrediente3 = new Ingrediente { Nome = Request.Form["I3"].ToString() };

                pizza.AcrescentarIngrediente(ingrediente1);
                pizza.AcrescentarIngrediente(ingrediente2);
                pizza.AcrescentarIngrediente(ingrediente3);

                sessaoAtual.Save(ingrediente1);
                sessaoAtual.Save(ingrediente2);
                sessaoAtual.Save(ingrediente3);

                sessaoAtual.Clear();

                Pizza p = sessaoAtual.Get<Pizza>(pizza.Id);

                return p.Id;
            }
            else
            {
                return 0;
            }
        }
コード例 #6
0
 public SessionProvider(SessionFactoryProvider sessionFactoryProvider)
 {
     _sessionFactory = sessionFactoryProvider.GetSessionFactory();
 }
コード例 #7
0
 public SessionProvider(SessionFactoryProvider sessionFactoryProvider)
 {
     _sessionFactory = sessionFactoryProvider.GetSessionFactory();
 }