예제 #1
0
        public UnitTest()
        {
            string jsonURL = "appsettings.json";
            // get the configuration file
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile(jsonURL, optional: true, reloadOnChange: true);

            IConfiguration configuration = builder.Build();

            // Test if we are getting the connection string
            Console.WriteLine("Connection String:\n");
            Console.WriteLine(configuration.GetConnectionString("PizzaStoreAppDB"));

            // Passing connection string to DBContext
            var OptionsBuilder = new DbContextOptionsBuilder <PizzaStoreAppContext>();

            OptionsBuilder.UseSqlServer(configuration.GetConnectionString("PizzaStoreAppDB"));

            var options = OptionsBuilder.Options;
            var context = new PizzaStoreAppContext(options);

            repo = new WebappRepository(context);
        }
예제 #2
0
 public AdminController(WebappRepository repo)
 {
     Repo = repo;
 }
예제 #3
0
 public DashboardController(WebappRepository repo)
 {
     Repo = repo;
 }
예제 #4
0
 public HomeController(WebappRepository repo)
 {
     Repo = repo;
 }