コード例 #1
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <DAL_EF.EF.RetailContext>();

            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["RetailContext"].ConnectionString);
            StandardKernel kernel = new StandardKernel(
                new UIModule(optionsBuilder.Options));

            IProductService  product  = kernel.Get <IProductService>();
            ICategoryService category = kernel.Get <ICategoryService>();
            ISupplierService supplier = kernel.Get <ISupplierService>();

            var cat = new CategoryDTO()
            {
                Name = "smth43242"
            };

            /*prod.Category=cat;
             * prod1.Category=cat;
             * prod2.Category=cat;*/

            /*category.Create(cat);
            *
            *  var prod = new ProductDTO () {Name= "smth", CategoryId=1, Price = 10};
            *  var prod1 = new ProductDTO () {Name= "smth1", CategoryId=1, Price= 20};
            *
            *
            *  var sup = new SupplierDTO () {Name="sm", Products= new List<ProductDTO> {prod, prod1}};
            *  supplier.Create(sup);*/

            //Console.WriteLine(product.GetWithMaxPrice().ProductId);
            //Console.WriteLine(product.GetWithMinPrice().ProductId);

            ProductGateway  prod  = new ProductGateway(new SqlContext());
            CategoryGateway categ = new CategoryGateway(new SqlContext());

            categ.Create(new ADOCategory()
            {
                Name = "Category"
            });

            prod.Create(new ADOProduct()
            {
                Name = "oof", Price = 10, CategoryId = 1
            });
        }