Exemple #1
0
        public Kart Create(Kart kart)
        {
            var kurt = _ctx.Add(kart).Entity;

            _ctx.SaveChanges();
            return(kurt);
        }
        public Product CreateProduct(Product product)
        {
            var prod = _ctx.Add(product).Entity;

            _ctx.SaveChanges();
            return(prod);
        }
        public User CreateUser(User user, Kart kart)
        {
            var users = _ctx.Add(user).Entity;

            users.ShoppingKart = kart;
            _ctx.SaveChanges();
            return(users);
        }
Exemple #4
0
        public static void Seed(WebshopAppContext context)
        {
            var categories = new List <Category>
            {
                new Category {
                    Name = "Electronics"
                },
                new Category {
                    Name = "Bullshits"
                },
                new Category {
                    Name = "Something Else"
                },
                new Category {
                    Name = "Whatever"
                },
                new Category {
                    Name = "Other"
                }
            };

            context.Categories.AddRange(categories);
            context.SaveChanges();

            for (int i = 0; i < 10; i++)
            {
                var product = new Product
                {
                    Name        = $"Product {i}",
                    Description = $"Description of product {i}",
                    Price       = (decimal)(new Random().NextDouble() * (new Random()).Next(10000)),
                    CategoryId  = new Random().Next(1, 6)
                };

                context.Products.Add(product);
            }

            for (int i = 0; i < 20; i++)
            {
                var blog = new Blog
                {
                    Title   = $"BlogTitle{i}",
                    Content = $"{i}{i}{i}{i}{i}{i}{i}{i}{i}{i}{i}{i}{i}{i} nqma takyv blog tova e voenno obuchenie. Vnimanie: Voenno Obuchenie. ALARM, Trevoga, Zaboga. Voenno obuchenie sssssssssssssssssssssss"
                };

                context.Blogs.Add(blog);
            }

            context.SaveChanges();
        }
Exemple #5
0
        public static void SeedPictures(WebshopAppContext context)
        {
            var blogs = context.Blogs.Take(10).ToList();

            for (int i = 1; i < 11; i++)
            {
                Blog blog = blogs.Skip(i - 1).First();

                blog.PictureUri = $"images/products/{i}.jpg";
            }

            context.SaveChanges();
        }