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);
        }
 public void AutoCriarBancoDeDados()
 {
     var sessionFactoryProvider = new SessionFactoryProvider();
     var sessionProvider = new SessionProvider(sessionFactoryProvider);
     sessionProvider.GetCurrentSession();
     sessionFactoryProvider.AutoCriarBancoDeDados();
 }
Exemple #3
0
        public void AutoCriarBancoDeDados()
        {
            var sessionFactoryProvider = new SessionFactoryProvider();
            var sessionProvider        = new SessionProvider(sessionFactoryProvider);

            sessionProvider.GetCurrentSession();
            sessionFactoryProvider.AutoCriarBancoDeDados();
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        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;
            }
        }
 public SessionProvider(SessionFactoryProvider sessionFactoryProvider)
 {
     _sessionFactory = sessionFactoryProvider.GetSessionFactory();
 }
 public SessionProvider(SessionFactoryProvider sessionFactoryProvider)
 {
     _sessionFactory = sessionFactoryProvider.GetSessionFactory();
 }