Ejemplo n.º 1
0
        public void TestMethod1()
        {
            return;

            Random gen = new Random();

            for (int i = 2; i <= 20; i++)
            {
                DateTime start = new DateTime(2000, 1, 1);
                int      range = (start.AddYears(5) - start).Days;
                start = start.AddDays(gen.Next(range));
                using (RecoEntities recoEntities = new RecoEntities())
                {
                    recoEntities.Database.Connection.Open();
                    var user = new User()
                    {
                        DataCreare = start,
                        Email      = "user" + i.ToString() + "@mailinator.com",
                        Forename   = "User",
                        Surname    = i.ToString(),
                        ImageUrl   = null,
                        Password   = "******",
                        Role       = "Vizitator"
                    };

                    recoEntities.Users.Add(user);
                    recoEntities.SaveChanges();
                }
            }
        }
Ejemplo n.º 2
0
        public void TestMethod1()
        {
            //return;
            Random gen = new Random();

            for (int i = 1; i <= 50; i++)
            {
                DateTime start = new DateTime(2005, 1, 1);
                int      range = (start.AddYears(5) - start).Days;
                start = start.AddDays(gen.Next(range));
                var     categoryId = i % 4 + 1;
                decimal price      = gen.Next(range) + 1;
                using (RecoEntities recoEntities = new RecoEntities())
                {
                    recoEntities.Database.Connection.Open();
                    var product = new Product()
                    {
                        DataCreare     = start,
                        CategorieId    = categoryId,
                        Nume           = (categoryId).ToString() + " " + ((i / 4) + 1),
                        Pret           = price,
                        PretCuDiscount = price,
                        Cantitate      = gen.Next(range)
                    };

                    recoEntities.Products.Add(product);
                    recoEntities.SaveChanges();
                }
            }
        }
Ejemplo n.º 3
0
        public void TestMethod1()
        {
            return;

            Random gen = new Random();

            for (int i = 1; i <= 200; i++)
            {
                DateTime start = new DateTime(2010, 1, 1);
                int      range = (start.AddYears(5) - start).Days;
                start = start.AddDays(gen.Next(range));
                var productIds = new List <int>();

                using (RecoEntities recoEntities = new RecoEntities())
                {
                    var productsNumber = gen.Next(5) + 1;
                    var userId         = gen.Next(19) + 2005;
                    productIds.Clear();
                    for (int j = 1; j <= productsNumber; j++)
                    {
                        productIds.Add(gen.Next(49) + 4009);
                    }

                    decimal sum = 0;
                    foreach (var productId in productIds)
                    {
                        var product = recoEntities.Products.Find(productId);
                        sum += product.PretCuDiscount;
                    }

                    var newSale = new Sale()
                    {
                        Address     = "-",
                        Phone       = "0790649098",
                        CreatedDate = start,
                        Price       = sum,
                        UserId      = userId
                    };
                    recoEntities.Sales.Add(newSale);
                    recoEntities.SaveChanges();

                    while (productIds.Count > 0)
                    {
                        var newItemSale = new SaleItem()
                        {
                            CreatedDate = start,
                            SaleId      = newSale.Id,
                            UserId      = newSale.UserId,
                            ProductId   = productIds[0],
                            Quantity    = productIds.Count(x => x == productIds[0])
                        };
                        recoEntities.SaleItems.Add(newItemSale);
                        recoEntities.SaveChanges();

                        var id = productIds[0];
                        productIds.RemoveAll(x => x == id);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public HomeController(RecoEntities recoEntities)
 {
     this.recoEntities = recoEntities;
 }
Ejemplo n.º 5
0
 public UserController(RecoEntities recoEntities)
 {
     this.recoEntities = recoEntities;
 }
Ejemplo n.º 6
0
 public SalesController(RecoEntities recoEntities)
 {
     this.recoEntities = recoEntities;
 }
Ejemplo n.º 7
0
 public ShoppingCartController(RecoEntities recoEntities)
 {
     this.recoEntities = recoEntities;
 }
Ejemplo n.º 8
0
 public CategoriesController(RecoEntities recoEntities)
 {
     this.recoEntities = recoEntities;
 }