public bool GenerateFor(Order[] orders)
        {
            OrderToWorker[] bindings;
            var             timeLogs = new List <TimeLog>();

            orders = orders.Where(o => o.Status == OrderStatusEnum.Finished || o.Status == OrderStatusEnum.InProgress).ToArray();
            long[] orderIds = orders.Select(o => o.Id).ToArray();

            using (var dbAccess = new WorkshopManagerContext())
            {
                bindings = dbAccess.OrderToWorkers
                           .Where(b => orderIds.Contains(b.OrderId)).ToArray();

                foreach (Order order in orders)
                {
                    var orderBindings   = bindings.Where(b => b.OrderId == order.Id).ToArray();
                    var mechanicianIds  = orderBindings.Select(b => b.WorkerId).ToArray();
                    var quarters        = GetAsOrderQuartersOfDay(order);
                    var contributions   = GenerateRandomContributions(quarters, mechanicianIds, order.Id);
                    var timeLogsOfOrder = InstantiateTimeLogs(order, contributions);
                    timeLogs.AddRange(timeLogsOfOrder);
                }
                dbAccess.BulkInsert <TimeLog>(timeLogs);
            }
            return(true);
        }
        public bool GenerateFor(Order[] orders)
        {
            try
            {
                List <Part> parts = new List <Part>();
                bool        createSubParts;
                int         subPartsCount;
                var         _rand = new Random();

                foreach (Order order in orders)
                {
                    var part = CreatePart(order.Id);
                    createSubParts = _rand.Next(1, 3) % 2 == 0;

                    if (createSubParts)
                    {
                        subPartsCount = _rand.Next(1, _maxSubPartsCount + 1);
                        var subParts = CreateSubPartsOf(order.Id, part, subPartsCount);
                        part.SubParts = subParts;
                        parts.AddRange(subParts);
                        part.SubParts = subParts;
                    }
                    parts.Add(part);
                }

                using (var dbAccess = new WorkshopManagerContext())
                {
                    dbAccess.BulkInsert <Part>(parts);
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }