Ejemplo n.º 1
0
        public async Task <Order> AddOrderRandom()
        {
            var orderNo = await documentNoGenerator.GetNewOrderNo();

            var randomNo = new Random(5).Next(10, 1000);

            var order = OrderSeed.GenerateOrder(randomNo, orderNo, dateTimeService);

            await dbContext.Orders.AddAsync(order);

            await dbContext.SaveChangesAsync();

            return(order);
        }
Ejemplo n.º 2
0
        public async Task SeedAsync(int retry = 0)
        {
            try
            {
                dbContext.Database.Migrate();

                if (await dbContext.Orders.CountAsync() == 0)
                {
                    dbContext.Orders.AddRange(OrderSeed.GetOrders(dateTimeService));
                    await dbContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                log.LogError("Error Occured while migrating/seeding.", ex);

                if (retry > 0)
                {
                    log.LogError("Retrying");
                    await SeedAsync(retry - 1);
                }
            }
        }