예제 #1
0
        //Creates a method of type interface that utilizes the
        //methods from the interface and the class that uses
        //that interface.
        //So we can use those methods in the UI
        public static IRepo CreateWatchStoreRepo()
        {
            var optionsBuilder = new DbContextOptionsBuilder <WatchStoreContext>();

            optionsBuilder.UseSqlServer(SecretConfiguration.ConnectionString);

            var MydbContext = new WatchStoreContext(optionsBuilder.Options);

            return(new WatchStoreRepository(MydbContext));
        }
        //Add logger later

        public WatchStoreRepository(WatchStoreContext dbContext)
        {
            try
            {
                MyDBContext = dbContext;
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("This is cannot be null.");
            }
        }
예제 #3
0
 public WatchesController(WatchStoreContext context)
 {
     _context = context;
 }