Beispiel #1
0
        private static void SeedIdentityDB()
        {
            var factory = new TenantContextFactory();
            var ctx     = factory.CreateDbContext(null);

            var role = new ApplicationRole
            {
                Id = Guid.NewGuid(),
                ConcurrencyStamp = Guid.NewGuid().ToString(),
                Name             = "Customer",
                NormalizedName   = "CUSTOMER"
            };

            ctx.Roles.Add(role);
            ctx.SaveChanges();
        }
Beispiel #2
0
        private static void SeedingProductTable()
        {
            Console.WriteLine("Seeding Product table...");

            var factory = new TenantContextFactory();
            var context = factory.CreateDbContext(null);

            //var category = context.ProductCategories.First();
            //var product = new Product
            //{
            //    Id = Guid.NewGuid(),
            //    Name = "RetailBay Test Product",
            //    Description = "Some long description",
            //    ProductCategoryId = category.Id,
            //    IsPublished = false,
            //    Slug = "retail_bay_test_product",
            //    DateCreated = DateTime.UtcNow,
            //    DateUpdated = DateTime.UtcNow
            //};

            //var productPrice = new ProductPrice
            //{
            //    Id = product.Id,
            //    Price = 22.99M,
            //    DateCreated = DateTime.UtcNow,
            //    DateUpdated = DateTime.UtcNow
            //};

            //product.ProductPrice = productPrice;
            // context.Products.Add(product);

            try
            {
                context.SaveChanges();

                Console.WriteLine("Success");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong: /n{ex.Message}");
            }
        }
Beispiel #3
0
        private static void SeedProductCategoryTable()
        {
            Console.WriteLine("Seeding ProductCategory table...");

            var factory = new TenantContextFactory();
            var context = factory.CreateDbContext(null);

            context.ProductCategories.Add(new ProductCategory
            {
                Id          = Guid.NewGuid(),
                Abrv        = "ELC",
                Name        = "Electronics",
                Slug        = "electronics",
                DateCreated = DateTime.UtcNow,
                DateUpdated = DateTime.UtcNow,
                IsDeleted   = false
            });

            context.ProductCategories.Add(new ProductCategory
            {
                Id          = Guid.NewGuid(),
                Abrv        = "FDD",
                Name        = "Food",
                Slug        = "food",
                DateCreated = DateTime.UtcNow,
                DateUpdated = DateTime.UtcNow,
                IsDeleted   = false
            });

            try
            {
                context.SaveChanges();

                Console.WriteLine("Success");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong: /n{ex.Message}");
            }
        }