public CityControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <City> cities = new List <City>();

            foreach (City c in context.City)
            {
                cities.Add(c);
            }

            if (cities.Count == 0)
            {
                City mock1 = new City("Test_City", 40.0, -8.0);
                City mock2 = new City("Second_Test_City", -40.0, 8.0);

                context.City.Add(mock1);
                context.City.Add(mock2);
                context.SaveChanges();
            }
            controller = new CityController(context);
        }
Exemplo n.º 2
0
        public CatalogControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <Catalog> catalogs = new List <Catalog>();

            foreach (Catalog c in context.Catalog)
            {
                catalogs.Add(c);
            }

            if (catalogs.Count == 0)
            {
                Catalog mock1 = new Catalog();
                mock1.Date = "06/01/2019";
                mock1.CatalogDescription = "This is a mock Catalog";
                mock1.CatalogName        = "Test_Catalog";
                mock1.CatalogProducts    = new List <CatalogProduct>();

                Catalog mock2 = new Catalog();
                mock2.Date = "06/01/2019";
                mock2.CatalogDescription = "This is another mock Catalog";
                mock2.CatalogName        = "Second_Test_Catalog";
                mock2.CatalogProducts    = new List <CatalogProduct>();

                Category mock3 = new Category();
                mock3.description = "This is a mock Category";
                mock3.name        = "Test_Category";
                mock3.parent      = null;

                Product mock4 = new Product();
                mock4.CatalogProducts    = new List <CatalogProduct>();
                mock4.CollectionProducts = new List <CollectionProduct>();
                mock4.ProductMaterials   = new List <ProductMaterial>();
                mock4.description        = "This is a mock Product";
                mock4.dimensions         = new List <Dimension>();
                mock4.name = "Test_Product";

                context.Catalog.Add(mock1);
                context.Catalog.Add(mock2);
                context.Category.Add(mock3);
                context.Product.Add(mock4);
                context.SaveChanges();
            }
            controller = new CatalogController(context);
        }
        public CollectionControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <Collection> collections = new List <Collection>();

            foreach (Collection c in context.Collection)
            {
                collections.Add(c);
            }

            if (collections.Count == 0)
            {
                Collection mock1 = new Collection();
                mock1.collectionName     = "Test_Collection";
                mock1.aestheticParameter = "Mock_Parameter";
                mock1.CollectionProducts = new List <CollectionProduct>();

                Collection mock2 = new Collection();
                mock2.collectionName     = "Second_Test_Collection";
                mock2.aestheticParameter = "Second_Mock_Parameter";
                mock2.CollectionProducts = new List <CollectionProduct>();

                Category mock3 = new Category();
                mock3.description = "This is a mock Category";
                mock3.name        = "Test_Category";
                mock3.parent      = null;

                Product mock4 = new Product();
                mock4.CatalogProducts    = new List <CatalogProduct>();
                mock4.CollectionProducts = new List <CollectionProduct>();
                mock4.ProductMaterials   = new List <ProductMaterial>();
                mock4.description        = "This is a mock Product";
                mock4.dimensions         = new List <Dimension>();
                mock4.name = "Test_Product";

                context.Collection.Add(mock1);
                context.Collection.Add(mock2);
                context.Category.Add(mock3);
                context.Product.Add(mock4);
                context.SaveChanges();
            }
            controller = new CollectionController(context);
        }
        public PriceControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <Price> prices = new List <Price>();

            foreach (Price p in context.Price)
            {
                prices.Add(p);
            }

            if (prices.Count == 0)
            {
                Price mock1 = new Price();
                mock1.date        = DateTime.Parse("2019-01-06");
                mock1.designation = "Test_Designation";
                mock1.price       = 25.55;

                Price mock2 = new Price();
                mock2.date        = DateTime.Parse("2019-01-07");
                mock2.designation = "Second_Test_Designation";
                mock2.price       = 50.0;

                Price mock3 = new Price();
                mock3.date        = DateTime.Parse("2019-01-08");
                mock3.designation = "Test_Designation";
                mock3.price       = 20.30;

                context.Price.Add(mock1);
                context.Price.Add(mock2);
                context.Price.Add(mock3);
                context.SaveChanges();
            }
            controller = new PriceController(context);
        }
        public FactoryControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <Factory> factories = new List <Factory>();

            foreach (Factory f in context.Factory)
            {
                factories.Add(f);
            }

            if (factories.Count == 0)
            {
                City mock1 = new City("Test_City", 40.0, -8.0);
                City mock2 = new City("Second_Test_City", -40.0, 8.0);
                City mock3 = new City("Third_Test_City", -20.0, 4.0);


                Factory mock4 = new Factory();
                mock4.City        = mock1;
                mock4.Description = "Test_Factory";

                Factory mock5 = new Factory();
                mock5.City        = mock2;
                mock5.Description = "Second_Test_Factory";

                context.City.Add(mock1);
                context.City.Add(mock2);
                context.City.Add(mock3);
                context.Factory.Add(mock4);
                context.Factory.Add(mock5);
                context.SaveChanges();
            }
            controller = new FactoryController(context);
        }
 public CombinationController(SiCContext context)
 {
     combinationRepository = new CombinationRepository(context);
 }
 public OrderRepository(SiCContext context)
 {
     this.context = context;
 }
 public CatalogController(SiCContext context)
 {
     catalogRepository = new CatalogRepository(context);
 }
Exemplo n.º 9
0
 public ProductRepository(SiCContext context)
 {
     this.context = context;
 }
 public DimensionRepository(SiCContext context)
 {
     this.context = context;
 }
Exemplo n.º 11
0
 public OrderController(SiCContext context)
 {
     orderRepository = new OrderRepository(context);
 }
Exemplo n.º 12
0
 public PriceRepository(SiCContext context)
 {
     this.context = context;
 }
Exemplo n.º 13
0
 public CatalogRepository(SiCContext context)
 {
     this.context = context;
 }
Exemplo n.º 14
0
 public MaterialController(SiCContext context)
 {
     materialRepository = new MaterialRepository(context);
 }
Exemplo n.º 15
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new SiCContext(
                       serviceProvider.GetRequiredService <DbContextOptions <SiCContext> >()))
            {
                if (context.Product.Any())
                {
                    return;   // DB has been seeded
                }

                City c   = new City("Aveiro", 40.641190, -8.653620);
                City c1  = new City("Beja", 38.015621, -7.865230);
                City c2  = new City("Braga", 41.545448, -8.426507);
                City c3  = new City("Braganca", 41.806114, -6.756738);
                City c4  = new City("Castelo Branco", 39.819714, -7.496466);
                City c5  = new City("Coimbra", 40.203316, -8.410257);
                City c6  = new City("Evora", 38.571430, -7.913502);
                City c7  = new City("Faro", 37.015362, -7.935110);
                City c8  = new City("Guarda", 40.537128, -7.267850);
                City c9  = new City("Leiria", 39.749535, -8.807683);
                City c10 = new City("Lisboa", 38.722252, -9.139337);
                City c11 = new City("Portalegre", 39.296707, -7.428476);
                City c12 = new City("Porto", 41.157944, -8.629105);
                City c13 = new City("Santarem", 39.236179, -8.687080);
                City c14 = new City("Setubal", 38.525406, -8.894100);
                City c15 = new City("Viana do Castelo", 41.691807, -8.834451);
                City c16 = new City("Vila Real", 41.295898, -7.746350);
                City c17 = new City("Viseu", 40.656586, -7.912471);

                Factory Factory = new Factory();
                Factory.City        = c12;
                Factory.Description = "Fabrica situada no Porto";

                Measure Depth  = new Measure(20.0, 40.0);
                Measure Height = new Measure(80);
                Measure Width  = new Measure(30, 50);

                Measure Depth_Part  = new Measure(10.0, 20.0);
                Measure Height_Part = new Measure(40);
                Measure Width_Part  = new Measure(15, 25);

                Dimension Dimension_Product = new Dimension();
                Dimension_Product.Depth  = Depth;
                Dimension_Product.Height = Height;
                Dimension_Product.Width  = Width;

                Dimension Dimension_Product_Part_A1 = new Dimension();
                Dimension_Product_Part_A1.Depth  = Depth_Part;
                Dimension_Product_Part_A1.Height = Height_Part;
                Dimension_Product_Part_A1.Width  = Width_Part;

                Dimension Dimension_Product_Part_A2 = new Dimension();
                Dimension_Product_Part_A2.Depth  = Depth_Part;
                Dimension_Product_Part_A2.Height = Height_Part;
                Dimension_Product_Part_A2.Width  = Width_Part;

                Price Finishing_Price = new Price();
                Finishing_Price.date        = DateTime.Parse("2019-01-06");
                Finishing_Price.designation = "Polimento";
                Finishing_Price.price       = 2.50;

                Price Material_Price = new Price();
                Material_Price.date        = DateTime.Parse("2019-01-06");
                Material_Price.designation = "Madeira";
                Material_Price.price       = 5.0;

                Finishing Finishing = new Finishing();
                Finishing.name               = "Polimento";
                Finishing.description        = "Acabamento que confere brilho e protecao do material quando aplicado";
                Finishing.MaterialFinishings = new List <MaterialFinishing>();
                Finishing.Prices             = new List <Price>();

                Material Material = new Material();
                Material.name               = "Madeira";
                Material.description        = "Madeira de pinho de elevada durabilidade";
                Material.MaterialFinishings = new List <MaterialFinishing>();
                Material.ProductMaterials   = new List <ProductMaterial>();
                Material.Prices             = new List <Price>();

                Category Category = new Category();
                Category.name        = "armario";
                Category.description = "Esta categoria representa o topo da taxonomia";

                Category Category_Part = new Category();
                Category_Part.name        = "gaveta";
                Category_Part.description = "Categoria desenvolvida para teste";
                Category_Part.parent      = Category;

                Product Product = new Product();
                Product.name               = "G8579";
                Product.description        = "Produto desenvolvido para teste";
                Product.category           = Category;
                Product.ProductMaterials   = new List <ProductMaterial>();
                Product.CatalogProducts    = new List <CatalogProduct>();
                Product.CollectionProducts = new List <CollectionProduct>();
                Product.dimensions         = new List <Dimension>();
                Product.dimensions.Add(Dimension_Product);

                Product Product_Part1 = new Product();
                Product_Part1.name               = "G8579_Part_A1";
                Product_Part1.description        = "Produto desenvolvido para teste";
                Product_Part1.category           = Category_Part;
                Product_Part1.ProductMaterials   = new List <ProductMaterial>();
                Product_Part1.CatalogProducts    = new List <CatalogProduct>();
                Product_Part1.CollectionProducts = new List <CollectionProduct>();
                Product_Part1.dimensions         = new List <Dimension>();
                Product_Part1.dimensions.Add(Dimension_Product_Part_A1);

                Product Product_Part2 = new Product();
                Product_Part2.name               = "G8579_Part_A2";
                Product_Part2.description        = "Produto desenvolvido para teste";
                Product_Part2.category           = Category_Part;
                Product_Part2.ProductMaterials   = new List <ProductMaterial>();
                Product_Part2.CatalogProducts    = new List <CatalogProduct>();
                Product_Part2.CollectionProducts = new List <CollectionProduct>();
                Product_Part2.dimensions         = new List <Dimension>();
                Product_Part2.dimensions.Add(Dimension_Product_Part_A2);

                Combination Combination_P_P1 = new Combination(Product, Product_Part1, true);

                Combination Combination_P_P2 = new Combination(Product, Product_Part2, false);

                Catalog Catalog = new Catalog();
                Catalog.CatalogName        = "Catalogo G8579";
                Catalog.CatalogDescription = "Catalogo desenvolvido para teste";
                Catalog.Date            = "2019-01-06";
                Catalog.CatalogProducts = new List <CatalogProduct>();

                Collection Collection = new Collection();
                Collection.collectionName     = "Madeira e mais Madeira";
                Collection.aestheticParameter = "Madeira";
                Collection.CollectionProducts = new List <CollectionProduct>();


                MaterialFinishing MF = new MaterialFinishing();
                MF.Finishing = Finishing;
                MF.Material  = Material;

                Finishing.MaterialFinishings.Add(MF);
                Material.MaterialFinishings.Add(MF);

                ProductMaterial PM = new ProductMaterial();
                PM.Material = Material;
                PM.Product  = Product;

                Product.ProductMaterials.Add(PM);
                Material.ProductMaterials.Add(PM);

                CatalogProduct CatP = new CatalogProduct();
                CatP.Catalog = Catalog;
                CatP.Product = Product;

                Product.CatalogProducts.Add(CatP);
                Catalog.CatalogProducts.Add(CatP);

                CollectionProduct ColP = new CollectionProduct();
                ColP.Collection = Collection;
                ColP.Product    = Product;

                Product.CollectionProducts.Add(ColP);
                Collection.CollectionProducts.Add(ColP);

                context.City.Add(c);
                context.City.Add(c1);
                context.City.Add(c2);
                context.City.Add(c3);
                context.City.Add(c4);
                context.City.Add(c5);
                context.City.Add(c6);
                context.City.Add(c7);
                context.City.Add(c8);
                context.City.Add(c9);
                context.City.Add(c10);
                context.City.Add(c11);
                context.City.Add(c12);
                context.City.Add(c13);
                context.City.Add(c14);
                context.City.Add(c15);
                context.City.Add(c16);
                context.City.Add(c17);

                context.Factory.Add(Factory);

                context.Measure.Add(Depth);
                context.Measure.Add(Height);
                context.Measure.Add(Width);
                context.Measure.Add(Depth_Part);
                context.Measure.Add(Height_Part);
                context.Measure.Add(Width_Part);

                context.Dimension.Add(Dimension_Product);
                context.Dimension.Add(Dimension_Product_Part_A1);
                context.Dimension.Add(Dimension_Product_Part_A2);

                context.Price.Add(Material_Price);
                context.Price.Add(Finishing_Price);

                context.Finishing.Add(Finishing);
                context.Material.Add(Material);

                context.Category.Add(Category);
                context.Category.Add(Category_Part);

                context.Product.Add(Product);
                context.Product.Add(Product_Part1);
                context.Product.Add(Product_Part2);

                context.Combination.Add(Combination_P_P1);
                context.Combination.Add(Combination_P_P2);

                context.Catalog.Add(Catalog);

                context.Collection.Add(Collection);

                MF.MaterialId  = Material.MaterialId;
                MF.FinishingId = Finishing.FinishingId;

                context.MaterialFinishing.Add(MF);

                PM.MaterialId = Material.MaterialId;
                PM.ProductId  = Product.ProductId;

                context.ProductMaterial.Add(PM);

                CatP.CatalogId = Catalog.CatalogId;
                CatP.ProductId = Product.ProductId;

                context.CatalogProduct.Add(CatP);

                ColP.CollectionId = Collection.CollectionId;
                ColP.ProdutctId   = Product.ProductId;

                context.CollectionProduct.Add(ColP);

                context.SaveChanges();
            }
        }
Exemplo n.º 16
0
 public CityController(SiCContext context)
 {
     cityRepository = new CityRepository(context);
 }
Exemplo n.º 17
0
 public RestrictionController(SiCContext context)
 {
     restrictionRepository = new RestrictionRepository(context);
 }
Exemplo n.º 18
0
 public RestrictionRepository(SiCContext context)
 {
     this.context = context;
 }
Exemplo n.º 19
0
 public CityRepository(SiCContext context)
 {
     this.context = context;
 }
 public CombinationRepository(SiCContext context)
 {
     this.context = context;
 }
 public FinishingRepository(SiCContext context)
 {
     this.context = context;
 }
Exemplo n.º 22
0
 public CollectionRepository(SiCContext context)
 {
     this.context = context;
 }
Exemplo n.º 23
0
 public ProductController(SiCContext context)
 {
     productRepository = new ProductRepository(context);
 }
 public PriceController(SiCContext context)
 {
     priceRepository = new PriceRepository(context);
 }
Exemplo n.º 25
0
 public FactoryRepository(SiCContext context)
 {
     this.context = context;
 }
 public CategoryRepository(SiCContext context)
 {
     this.context = context;
 }
 public DimensionController(SiCContext context)
 {
     dimensionRepository = new DimensionRepository(context);
 }
 public MaterialRepository(SiCContext context)
 {
     this.context = context;
 }
 public CategoryController(SiCContext context)
 {
     categoryRepository = new CategoryRepository(context);
 }
Exemplo n.º 30
0
 public FactoryController(SiCContext context)
 {
     factoryRepository = new FactoryRepository(context);
 }