protected virtual void Application_Start(Object sender, EventArgs e)
        {
            var connectionString = ConfigurationManager.ConnectionStrings ["AspSQLProvider"];

            MvcStoreApplication.InitDb(connectionString.ConnectionString);

            var root = SiteMap.RootNode;

            EntitySiteMappingConfiguration.Configure()
            .Map <Category> ().To(root.Find("Category"))
            .Map <Product> ().To(root.Find("Product"))
            .Map <Order> ().To(root.Find("Order"))
            .Map <Cart> ().To(root.Find("Cart"));
        }
Ejemplo n.º 2
0
 public void Init()
 {
     MvcStoreApplication.InitDb("store.db", "users.db");
     sessionFactory = MvcStoreApplication.CreateSessionFactory();
     MvcStoreApplication.LoadDummyData(sessionFactory);
 }
Ejemplo n.º 3
0
    static void Main(string[] args)
    {
        Console.WriteLine("Getting configuration ...");
        var connectionString
            = ConfigurationManager.ConnectionStrings ["AspSQLProvider"].ToString();

        Console.WriteLine("ConnectionString: " + connectionString);

        // Delete and recreate db
        Console.WriteLine("Tying to delete database ...");
        var pDropDb = Process.Start("/usr/bin/dropdb", "mvcstore");

        pDropDb.WaitForExit();

        Console.WriteLine();
        Console.WriteLine("Trying to create database ...");
        var pCreateDb = Process.Start("/usr/bin/createdb", "mvcstore");

        pCreateDb.WaitForExit();
        Console.WriteLine();

        // setup store schema
        Console.WriteLine("Setting up store schema ...");
        MvcStoreApplication.InitDb(connectionString, true);
        Console.WriteLine();

        // loading dummy data into store schema
        Console.WriteLine("Loading dummy data into store schema ...");
        var pLoadData = Process.Start("/usr/bin/psql", DbName + " -f populatedb.sql");

        pLoadData.WaitForExit();
        Console.WriteLine();

        // loading product images into db
        var picgen = new PictureGenerator {
            Size = 250
        };
        var repo = new NHibernateRepository <Product> ();

        foreach (var item in repo.GetItems())
        {
            item.Image = picgen.Next();
            repo.UpdateItem(item);
        }

        // setup membership schema
        Console.WriteLine("Setting up membership schema ...");
        var pExeMemSchema = Process.Start("/usr/bin/psql",
                                          DbName + " -f DatabaseSchema.sql");

        pExeMemSchema.WaitForExit();
        Console.WriteLine();

        // setup membership admin role and user
        Console.WriteLine("Setting up membership admin ...");
        var pExeMemAdmin = Process.Start("/usr/bin/psql",
                                         DbName + " -f MembershipRolesSetup.sql");

        pExeMemAdmin.WaitForExit();
        Console.WriteLine();

        Console.WriteLine("Complete.");
    }