Esempio n. 1
0
        public static async Task AddTestData(
            CoreWebApiTestDBContext context,
            UserDbContext userDbContect, UserManager <IdentityUser> userManager)
        {
            if (context.Products.Any())
            {
                // Already has data
                return;
            }


            ProductCategory cat1 = new ProductCategory();

            cat1.ProductCategoryName = "Cell Phones";


            cat1.Products.Add(new Product
            {
                ProductTitle       = "Android Phone V1",
                ProductDescription = "Android Phone V1 Description",
                ProductPrice       = 1000,
                ProductImagePath   = "",
            });
            cat1.Products.Add(new Product
            {
                ProductTitle       = "iPhone Phone V1",
                ProductDescription = "iPhone Phone V1 Description",
                ProductPrice       = 2000,
                ProductImagePath   = "",
            });



            ProductCategory cat2 = new ProductCategory();

            cat2.ProductCategoryName = "Electronics";


            cat2.Products.Add(new Product
            {
                ProductTitle       = "Samsung TV",
                ProductDescription = "Samsung TV Description",
                ProductPrice       = 10000,
                ProductImagePath   = "",
            });
            cat2.Products.Add(new Product
            {
                ProductTitle       = "Sony TV",
                ProductDescription = "Sony TV Description",
                ProductPrice       = 20000,
                ProductImagePath   = "",
            });

            context.ProductCategories.Add(cat1);
            context.ProductCategories.Add(cat2);
            await context.SaveChangesAsync();

            var user = new IdentityUser {
                UserName = "******", Email = "*****@*****.**"
            };
            var result = await userManager.CreateAsync(user, "Test@@123");
        }
Esempio n. 2
0
 public ProductCategoryRepository(CoreWebApiTestDBContext context, IDistributedCache cache)
 {
     _context = context;
     _cache   = cache;
 }