예제 #1
0
        private static void AddTestData(ECommerceApiContext eCommerceApiContext)
        {
            Configuration ramConfig = new Configuration()
            {
                configugurationEnumType = ConfigugurationEnum.RAM,
                Id    = 1,
                Name  = "8GB RAM",
                Price = 45.90M
            };

            Configuration colourConfig = new Configuration()
            {
                configugurationEnumType = ConfigugurationEnum.Colour,
                Id    = 2,
                Name  = "Blue",
                Price = 30.90M
            };

            Configuration hddConfig = new Configuration()
            {
                configugurationEnumType = ConfigugurationEnum.HDD,
                Id    = 3,
                Name  = "500GB",
                Price = 30.90M
            };

            eCommerceApiContext.Configurations.Add(ramConfig);
            eCommerceApiContext.Configurations.Add(colourConfig);
            eCommerceApiContext.Configurations.Add(hddConfig);

            var laptop = new Laptop()
            {
                Id = 1, Name = "Dell", Price = 360.60M, Configuration = new List <Configuration> {
                    ramConfig, hddConfig
                }
            };

            var laptop2 = new Laptop()
            {
                Id = 2, Name = "Lenova", Price = 400.30M
                , Configuration = new List <Configuration> {
                    ramConfig, colourConfig
                }
            };

            var shoppingCart = new ShoppingCart {
                Id = 1, Laptops = new List <Laptop> {
                    laptop
                }
            };

            eCommerceApiContext.Laptops.Add(laptop);
            eCommerceApiContext.Laptops.Add(laptop2);
            eCommerceApiContext.ShoppingCarts.Add(shoppingCart);
            eCommerceApiContext.SaveChanges();
        }
예제 #2
0
 public ConfigValidator(ECommerceApiContext eCommerceApiContext)
 {
     _eCommerceApiContext = eCommerceApiContext;
 }
예제 #3
0
 public LaptopRepository(ECommerceApiContext eCommerceApiContext)
 {
     _eCommerceApiContext = eCommerceApiContext;
 }
 public ConfigurationRepository(ECommerceApiContext eCommerceApiContext)
 {
     _eCommerceApiContext = eCommerceApiContext;
 }
예제 #5
0
 public LaptopValidator(ECommerceApiContext eCommerceApiContext)
 {
     _eCommerceApiContext = eCommerceApiContext;
 }
 public ShoppingCartRepository(ECommerceApiContext eCommerceApiContext)
 {
     _eCommerceApiContext = eCommerceApiContext;
 }
 public ShoppingCartValidator(ECommerceApiContext eCommerceApiContext)
 {
     _eCommerceApiContext = eCommerceApiContext;
 }