Esempio n. 1
0
        private static List <Transaction> GetTransactionList(int branchId, List <DateTime> transctionDateTime)
        {
            List <Transaction> finalTransactionList = new List <Transaction>();

            foreach (var dateTime in transctionDateTime)
            {
                int transactionProductCount = random.Next(1, 8);

                //Transaction Detail list for the transaction
                List <TransactionDetail> transactionDetailList = new List <TransactionDetail>();
                Transaction transaction = new Transaction()
                {
                    BranchID        = branchId,
                    CustomerID      = 1,
                    EmployeeID      = 1,
                    TransactionDate = dateTime
                };

                List <int> productIdList = new List <int>();

                for (int i = 1; i <= transactionProductCount; i++)
                {
                    int productId = 0;

                    do
                    {
                        productId = random.Next(1, 20);
                        if (!productIdList.Contains(productId))
                        {
                            break;
                        }
                    } while (true);

                    short quantity = Convert.ToInt16(random.Next(1, 20));

                    productIdList.Add(productId);

                    TransactionDetail transactionDetail = new TransactionDetail {
                        ProductID = productId, Quantity = quantity
                    };
                    transactionDetailList.Add(transactionDetail);
                }

                transaction.TransactionDetails = transactionDetailList;
                finalTransactionList.Add(transaction);
            }

            return(finalTransactionList);
        }
Esempio n. 2
0
        private static List<Transaction> GetTransactionList(int branchId, List<DateTime> transctionDateTime)
        {
            List<Transaction> finalTransactionList = new List<Transaction>();

            foreach (var dateTime in transctionDateTime)
            {
                int transactionProductCount = random.Next(1, 8);

                //Transaction Detail list for the transaction
                List<TransactionDetail> transactionDetailList = new List<TransactionDetail>();
                Transaction transaction = new Transaction()
                {
                    BranchID = branchId,
                    CustomerID = 1,
                    EmployeeID = 1,
                    TransactionDate = dateTime
                };

                List<int> productIdList = new List<int>();

                for (int i = 1; i <= transactionProductCount; i++)
                {
                    int productId = 0;

                    do
                    {
                        productId = random.Next(1, 20);
                        if (!productIdList.Contains(productId))
                        {
                            break;
                        }

                    } while (true);

                    short quantity = Convert.ToInt16(random.Next(1, 20));

                    productIdList.Add(productId);

                    TransactionDetail transactionDetail = new TransactionDetail { ProductID = productId, Quantity = quantity };
                    transactionDetailList.Add(transactionDetail);
                }

                transaction.TransactionDetails = transactionDetailList;
                finalTransactionList.Add(transaction);
            }

            return finalTransactionList;
        }