public async Task <bool> GenerateDailyCounting(int storeId, DateTime date)
        {
            var dailyCounting = new InventoryDailyCounting
            {
                Id      = Guid.NewGuid(),
                StoreId = storeId,
                Date    = date.Date,
                Closed  = false,
                Items   = GetItems()
            };

            return((await DailyCountingSimulationRepository.CreateDailyCountingAsync(dailyCounting).ConfigureAwait(false)) > 0);
        }
        private List <InventoryDailyCounting> GetOrCreateTestData(int storeId)
        {
            var invCountingDaily1 = new InventoryDailyCounting()
            {
                Id      = Guid.NewGuid(),
                StoreId = storeId,
            };

            invCountingDaily1.Items = new Collection <InventoryDailyCountingItem>();
            invCountingDaily1.Items.Add(new InventoryDailyCountingItem
            {
                Id = Guid.NewGuid(),
                DailyCountingId = invCountingDaily1.Id,
                ItemCodeNo      = "124658777",
                Category        = "3121",
                ItemText        = "testText 100g",
                StartQty        = -5
            });
            invCountingDaily1.Items.Add(new InventoryDailyCountingItem
            {
                Id = Guid.NewGuid(),
                DailyCountingId = invCountingDaily1.Id,
                ItemCodeNo      = "5799234522",
                Category        = "3121",
                ItemText        = "itemtestText 150g",
                StartQty        = -999
            });

            List <InventoryDailyCounting> dailyCountingsInDb;

            using (var scope = Factory.Factories[0].Server.Host.Services.CreateScope())
            {
                var context = scope.ServiceProvider.GetRequiredService <DailyCountingDataContext>();
                dailyCountingsInDb = context.InventoryDailyCountings.Where(c => c.StoreId == storeId).ToList();
                if (dailyCountingsInDb.Count == 0)
                {
                    context.InventoryDailyCountings.Add(invCountingDaily1);
                    context.SaveChanges();
                    dailyCountingsInDb = context.InventoryDailyCountings.Where(c => c.StoreId == storeId).ToList();
                }
            }
            return(dailyCountingsInDb);
        }
        public async Task <int> CreateDailyCountingAsync(InventoryDailyCounting dailyCounting)
        {
            await DailyCountingContext.InventoryDailyCountings.AddAsync(dailyCounting).ConfigureAwait(false);

            return(await DailyCountingContext.SaveChangesAsync().ConfigureAwait(false));
        }