示例#1
0
        public WeeklySummary GetWeeklySummary(DateTime currentLocalTime, Orders.OrderService orderService)
        {
            WeeklySummary result = new WeeklySummary();

            AddThisWeekData(result, currentLocalTime, orderService);
            AddLastWeekData(result, currentLocalTime, orderService);

            return(result);
        }
示例#2
0
        private void AddLastWeekData(WeeklySummary result, DateTime currentLocalTime, Orders.OrderService orderService)
        {
            Utilities.DateRange rangeData = new Utilities.DateRange();
            rangeData.RangeType = Utilities.DateRangeType.LastWeek;
            rangeData.CalculateDatesFromType(currentLocalTime);

            int totalCount = 0;
            List <Orders.OrderTransaction> data = orderService.Transactions.FindForReportByDateRange(rangeData.StartDate.ToUniversalTime(),
                                                                                                     rangeData.EndDate.ToUniversalTime(),
                                                                                                     _StoreId, int.MaxValue, 1, ref totalCount);

            decimal m = 0;
            decimal t = 0;
            decimal w = 0;
            decimal r = 0;
            decimal f = 0;
            decimal s = 0;
            decimal y = 0;

            foreach (Orders.OrderTransaction ot in data)
            {
                switch (ot.TimeStampUtc.ToLocalTime().DayOfWeek)
                {
                case DayOfWeek.Monday:
                    m += ot.AmountAppliedToOrder;
                    break;

                case DayOfWeek.Tuesday:
                    t += ot.AmountAppliedToOrder;
                    break;

                case DayOfWeek.Wednesday:
                    w += ot.AmountAppliedToOrder;
                    break;

                case DayOfWeek.Thursday:
                    r += ot.AmountAppliedToOrder;
                    break;

                case DayOfWeek.Friday:
                    f += ot.AmountAppliedToOrder;
                    break;

                case DayOfWeek.Saturday:
                    s += ot.AmountAppliedToOrder;
                    break;

                case DayOfWeek.Sunday:
                    y += ot.AmountAppliedToOrder;
                    break;
                }
            }

            result.MondayLast    = m;
            result.TuesdayLast   = t;
            result.WednesdayLast = w;
            result.ThursdayLast  = r;
            result.FridayLast    = f;
            result.SaturdayLast  = s;
            result.SundayLast    = y;
        }