Esempio n. 1
0
        public List <Transaction> MakeTransactionListByTotalMealOrderAndMonth(List <Order> listOfOrder, int operatedByUserId, int month, int year)
        {
            List <Transaction> listOfTransaction = new List <Transaction>();

            DateTime currentTime = BdTime.GetCurrentDate();



            ExpenseManager expenseManager = new ExpenseManager();

            double currentMealPrice = expenseManager.GetAverageMealPriceOfMonth(month, year);

            foreach (Order order in listOfOrder)
            {
                Transaction newTransaction = new Transaction();

                newTransaction.OperatedByUserId = operatedByUserId;
                newTransaction.OperatedToUserId = order.UserId;
                newTransaction.Amount           = currentMealPrice * (order.Meal1 + order.Meal2 + order.Meal3);
                newTransaction.Date             = currentTime.ToString("yyyy-MM-dd");
                newTransaction.Time             = currentTime.ToString("mm:hh ttt");
                newTransaction.TransactionType  = Transaction.remove;

                listOfTransaction.Add(newTransaction);
            }


            return(listOfTransaction);
        }
Esempio n. 2
0
        public ActionResult Info()
        {
            ExpenseManager expenseManager = new ExpenseManager();

            DateTime currentTime             = BdTime.GetCurrentDate();
            double   averageMealPriceOfMonth = expenseManager.GetAverageMealPriceOfMonth(currentTime.Month, currentTime.Year);

            ViewBag.averageMealPriceOfMonth = Math.Round(averageMealPriceOfMonth, 3, MidpointRounding.ToEven);
            return(View());
        }
Esempio n. 3
0
        public void CalculateForMonth()
        {
            DateTime currentDate    = BdTime.GetCurrentDate();
            DateTime oneMonthBefore = currentDate.AddMonths(-1);


            MonthCheckManager monthCheckManager = new MonthCheckManager();
            OrderManager      orderManager      = new OrderManager();
            ExpenseManager    expenseManager    = new ExpenseManager();


            if (monthCheckManager.GetMonthCheckByMonthYear(oneMonthBefore.Month, oneMonthBefore.Year) == null)
            {
                TransactionManager transactionManager = new TransactionManager();


                User currentUser = SetSession.GetCurrentUser();

                List <Order> totalMealOfOrderList = orderManager.TotalMealForMonthByUserList(oneMonthBefore.Month, oneMonthBefore.Year);

                List <Transaction> listOfTransaction =
                    transactionManager.MakeTransactionListByTotalMealOrderAndMonth
                        (totalMealOfOrderList, currentUser.Id, oneMonthBefore.Month, oneMonthBefore.Year);

                transactionManager.MakeTransactionFromTransactionListForTotalCalculation(listOfTransaction);


                double averageMealPriceOfMonth = expenseManager.GetAverageMealPriceOfMonth(oneMonthBefore.Month, oneMonthBefore.Year);


                orderManager.AddMealPriceForAllOrderByMonth(oneMonthBefore.Month, oneMonthBefore.Year, averageMealPriceOfMonth);


                monthCheckManager.AddCheckForMonthYear(oneMonthBefore.Month, oneMonthBefore.Year);
            }
        }