Esempio n. 1
0
        public IEnumerable <SalesGroup> GetSalesByChannel(DateTime start, DateTime end, GroupingPeriod period)
        {
            List <SalesGroup> list = new List <SalesGroup>();

            if (period == GroupingPeriod.All)
            {
                foreach (string channel in channels)
                {
                    decimal    amount = rnd.Next(4750, 87756);
                    int        units  = (int)amount / 15;
                    SalesGroup sg     = new SalesGroup(channel, amount, units, start, end);
                    list.Add(sg);
                }
                return(list);
            }
            else
            {
                TimeSpan step;
                DateTime actualStart;
                int      randomStart;
                int      randomEnd;
                switch (period)
                {
                case GroupingPeriod.Hour:
                    step        = new TimeSpan(1, 0, 0);
                    actualStart = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0);
                    randomStart = 50000;
                    randomEnd   = 250000;
                    break;

                case GroupingPeriod.Day:
                    step        = new TimeSpan(24, 0, 0);
                    actualStart = new DateTime(start.Year, start.Month, start.Day, 0, 0, 0);
                    randomStart = 900000;
                    randomEnd   = 150000000;
                    break;

                case GroupingPeriod.All:
                    return(null);

                default:
                    throw new Exception();
                }
                foreach (string channel in channels)
                {
                    for (DateTime date = actualStart; date <= end; date += step)
                    {
                        if (period == GroupingPeriod.Hour && (date.Hour < 8 || date.Hour > 18))
                        {
                            continue;
                        }
                        decimal    amount = rnd.Next(randomStart, randomEnd);
                        int        units  = (int)amount / 15;
                        SalesGroup sg     = new SalesGroup(channel, amount, units, date, date + step);
                        list.Add(sg);
                    }
                }
                return(list);
            }
        }
Esempio n. 2
0
        public IEnumerable <SalesGroup> GetSalesBySector(DateTime start, DateTime end, GroupingPeriod period)
        {
            List <SalesGroup> list = new List <SalesGroup>();

            foreach (string sector in sectors)
            {
                decimal    amount = rnd.Next(4750, 87756);
                int        units  = (int)amount / 15;
                SalesGroup sg     = new SalesGroup(sector, amount, units, start, end);
                list.Add(sg);
            }
            return(list);
        }