Esempio n. 1
0
        public void InitializeFromRange()
        {
            if (RangeFilter.From.Value != null && RangeFilter.To.Value != null)
            {
                var from = RangeFilter.From.Value.Value;
                var to   = RangeFilter.To.Value.Value;
                var diff = (to.Month - from.Month) + 1;

                // Always set year
                Year = Years.SingleOrDefault(i => i.Value == from.Year);
                if (diff == 12)
                {
                    // one year
                }
                else if (diff == 3)
                {
                    // Quater
                    Quater = Quaters.SingleOrDefault(i => i.Value == from.GetQuater());
                }
                else
                {
                    // OK, lets assume it's a Month
                    Month = Months.SingleOrDefault(i => i.Value == from.Month);
                }
            }
            else
            {
                // Default to current year
                Year = Years.SingleOrDefault(i => i.Value == DateTime.Today.Year);
            }
        }