Beispiel #1
0
        private static void InitProducts(OrganiDbContext db)
        {
            if (!db.Products.Any())
            {
                for (int i = 1; i <= 12; i++)
                {
                    int categoryId = 1;
                    if (i % 2 == 0)
                    {
                        categoryId = 2;
                    }
                    else if (i % 3 == 0)
                    {
                        categoryId = 3;
                    }

                    var product = new Product
                    {
                        CategoryId       = categoryId,
                        Name             = $"{i}Vetgetable’s Package",
                        price            = (5 + i),
                        Quantity         = 1,
                        Unit             = "kq",
                        ShortDescription = $"{i}Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Sed porttitor lectus nibh. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Proin eget tortor risus."
                    };

                    product.Images = new List <ProductImage>();
                    product.Images.Add(new ProductImage {
                        IsMain = true,
                        Path   = $"product-{i}.jpg"
                                 //ProductId=product.Id Bu avtamatik goturulur
                    });
                    product.Images.Add(new ProductImage
                    {
                        IsMain = false,
                        Path   = "thumb-1.jpg"
                    });
                    product.Images.Add(new ProductImage
                    {
                        IsMain = false,
                        Path   = "thumb-2.jpg"
                    });
                    product.Images.Add(new ProductImage
                    {
                        IsMain = false,
                        Path   = "thumb-3.jpg"
                    });
                    product.Images.Add(new ProductImage
                    {
                        IsMain = false,
                        Path   = "thumb-4.jpg"
                    });

                    db.Products.AddRange(product);
                }


                db.SaveChanges();
            }
        }
Beispiel #2
0
        private static void InitCategories(OrganiDbContext db)
        {
            if (!db.Categories.Any())
            {
                db.Categories.AddRange(new Category
                {
                    Name             = "Fresh Fruit",
                    IsFeaturedFilter = true
                },
                                       new Category
                {
                    Name             = "Dried Fruit",
                    IsFeaturedFilter = true
                },
                                       new Category
                {
                    Name             = "Fastfood",
                    IsFeaturedFilter = true
                },
                                       new Category
                {
                    Name             = "Vegetables",
                    IsFeaturedFilter = true
                });

                db.SaveChanges();
            }
        }
Beispiel #3
0
 private static void InitAppInfo(OrganiDbContext db)
 {
     if (!db.AppInfos.Any())
     {
         db.AppInfos.Add(new AppInfo {
             AppTitle      = "Organi",
             Address       = "Address: 60-49 Road 11378 New York",
             Email         = "*****@*****.**",
             Phone         = "+994 50 245 44 44",
             LogoPath      = "logo.png",
             HashTag       = "#developerleri#qoruyaq",
             FacebookLink  = "http://facebook.com",
             InstagramLink = "http://instagram.com",
             TwitterLink   = "http://twitter.com",
             OpenTime      = "10:00 am to 23:00 pm"
         });
         db.SaveChanges();
     }
 }