Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Refill refiller = new Refill();
            //refiller.Start();

            //Playground playground = new Playground();

            VendingDBService db = new VendingDBService();

            CategoryItem category = new CategoryItem()
            {
                Name  = "Test",
                Noise = "Test Munch"
            };

            category.Id = db.AddCategoryItem(category);
            category    = db.GetCategoryItem(category.Id);

            category.Name  = "A";
            category.Noise = "A,A,A";
            db.UpdateCategoryItem(category);
            category = db.GetCategoryItem(category.Id);

            db.DeleteCategoryItem(category.Id);
            var categories = db.GetCategoryItems();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                //options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDistributedMemoryCache();
            services.AddSession(options =>
            {
                // Sets session expiration to 20 minuates
                options.IdleTimeout     = TimeSpan.FromMinutes(20);
                options.Cookie.HttpOnly = true;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            string connectionString = Configuration.GetConnectionString("DefaultConnection");
            var    db = new VendingDBService(connectionString);
            //var db = new MockVendingDBService();
            var log = new LogDBService(connectionString);

            services.AddSingleton <IVendingMachine, VendingMachine>(m => new VendingMachine(db, log));
            services.AddScoped <IVendingService, VendingDBService>(m => new VendingDBService(connectionString));
            //services.AddScoped<IVendingService, MockVendingDBService>(m => new MockVendingDBService());
        }
        static void Main(string[] args)
        {
            string            connectionString = ConfigurationManager.ConnectionStrings["LocalConnection"].ConnectionString;
            var               db  = new VendingDBService(connectionString);
            var               log = new LogFileService();
            VendingMachine    vm  = new VendingMachine(db, log);
            VendingMachineCLI cli = new VendingMachineCLI(vm);

            cli.Run();
        }
Ejemplo n.º 4
0
        //[TestMethod]
        public void PopulateDatabase()
        {
            IVendingService db = new VendingDBService(_connectionString);

            //IVendingService db = new MockVendingDBService();

            TestManager.PopulateDatabaseWithUsers(db);
            TestManager.PopulateDatabaseWithInventory(db);
            TestManager.PopulateDatabaseWithTransactions(db);
        }
Ejemplo n.º 5
0
        //[TestMethod]
        public void PopulateDatabase()
        {
            IVendingService db = new VendingDBService(_connectionString);
            //IVendingService db = new MockVendingDBService();

            //TestManager.PopulateDatabaseWithUsers(db);
            //TestManager.PopulateDatabaseWithInventory(db);
            //TestManager.PopulateDatabaseWithTransactions(db);

            //ILogService log = new LogDBService(_connectionString);
            //TestManager.PopulateLogFileWithOperations(db, log);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            string connectionString = Configuration.GetConnectionString("DefaultConnection");
            var    db = new VendingDBService(connectionString);
            //var db = new MockVendingDBService();
            var log = new LogDBService(connectionString);

            services.AddSingleton <IVendingMachine>(m => new VendingMachine(db, log));
        }
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("DefaultConnection");

            var db = new VendingDBService(connectionString);
            //var db = new MockVendingDBService();

            var            log = new LogFileService();
            VendingMachine vm  = new VendingMachine(db, log);
            VndrCLI        cli = new VndrCLI(vm);

            cli.Run();
        }