Exemple #1
0
        public void Fill(ICrudRepository repository)
        {
            for (var i = 0; i < _clientNumber; i++)
            {
                var client = new Client(
                    GetRandStr(6),
                    GetRandStr(8),
                    $"{GetRandStr(5)}.{i}@{GetRandStr(2)}.com",
                    GetRandStr(6));
                repository.AddClient(client);
            }

            for (var i = 0; i < _productNumber; i++)
            {
                var product = new Product(
                    Guid.NewGuid(),
                    $"Product_{i}",
                    GetRandStr(10),
                    GetRandStr(5));
                repository.AddProduct(product);

                var offer = new Offer(
                    product,
                    new decimal(Random.NextDouble()) * 21.37m,
                    new decimal(Random.NextDouble()),
                    Random.Next(5, 100));
                repository.AddOffer(offer);
            }

            for (var i = 0; i < 2 * _eventNumber / 3; i++)
            {
                var facture = new Facture(
                    Guid.NewGuid(),
                    repository.GetAllClients().ToArray()[Random.Next(0, _clientNumber)],
                    repository.GetAllOffers().ToArray()[Random.Next(0, _productNumber)],
                    DateTimeOffset.Now.AddDays(Random.Next(-360, -30)).AddHours(Random.Next(-12, 12)),
                    Random.Next(1, 20));
                repository.AddEvent(facture);
            }

            for (var i = 0; i < _eventNumber / 3; i++)
            {
                var factures = repository.GetAllEvents().Where(e => e is Facture).Cast <Facture>().ToArray();
                var f        = factures[Random.Next(0, factures.Length)];
                var returned = new Return(Guid.NewGuid(), f, f.Date.AddDays(Random.Next(1, 30)), Random.Next(1, f.BoughtProducts + 1));
                repository.AddEvent(returned);
            }
        }
Exemple #2
0
        public void Fill(ICrudRepository repository)
        {
            var c1 = new Client("Maciej", "Błażewicz", "*****@*****.**", "Rawa Mazowiecka");
            var c2 = new Client("Sebastian", "Nawrocki", "*****@*****.**", "Łódź");

            repository.AddClient(c1);
            repository.AddClient(c2);

            var p1 = new Product(Guid.NewGuid(), "Granat", "Jadalny owoc, najczęściej koloru czerwonego", "Artykuły spożywcze");
            var p2 = new Product(Guid.NewGuid(), "Klawiatura mechaniczna", "Klawiatura z niskimi czasami opóźnień", "Elektronika");
            var p3 = new Product(Guid.NewGuid(), "Granat", "Pocisk rażący odłamkami i energią wybuchu", "Broń");

            repository.AddProduct(p1);
            repository.AddProduct(p2);
            repository.AddProduct(p3);

            var o1 = new Offer(p1, 14.50m, 0.05m, 40);
            var o2 = new Offer(p2, 450.00m, 0.23m, 5);
            var o3 = new Offer(p3, 1500.00m, 0.23m, 2);

            repository.AddOffer(o1);
            repository.AddOffer(o2);
            repository.AddOffer(o3);

            var f1 = new Facture(Guid.NewGuid(), c2, o1, DateTimeOffset.Now.AddDays(-7), 5);
            var f2 = new Facture(Guid.NewGuid(), c1, o2, DateTimeOffset.Now.AddDays(-6), 1);
            var f3 = new Facture(Guid.NewGuid(), c1, o3, DateTimeOffset.Now.AddDays(-5), 3);
            var f4 = new Facture(Guid.NewGuid(), c1, o1, DateTimeOffset.Now.AddDays(-2), 5);
            var f5 = new Facture(Guid.NewGuid(), c2, o2, DateTimeOffset.Now.AddDays(-2), 5);
            var r1 = new Return(Guid.NewGuid(), f1, DateTimeOffset.Now, 3);

            repository.AddEvent(f1);
            repository.AddEvent(f2);
            repository.AddEvent(f3);
            repository.AddEvent(f4);
            repository.AddEvent(f5);
            repository.AddEvent(r1);
        }