Example #1
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.");
    }