Ejemplo n.º 1
0
        public async static Task SeedData(IEcommerceUnitOfWork unitOfWork, ICurrencyConverter converter)
        {
            //Creating products
            List <Product> products = new List <Product>();
            var            rand     = new Random();

            for (char c = 'A'; c <= 'Z'; c++)
            {
                var price = new decimal(rand.NextDouble());
                products.Add(new Product($"Product {c}", Money.Of(price, converter.GetBaseCurrency().Code)));
            }

            await unitOfWork.ProductRepository.AddRange(products);

            await unitOfWork.CommitAsync();
        }