Beispiel #1
0
        public DimDate(DateTime d)
        {
            var j = new PersianDateTime(d);

            Date          = d;
            LongDate      = d.ToLongDateString();
            DayOfWeek     = (int)d.DayOfWeek + 1;
            DayOfWeekName = d.DayOfWeek.ToString();
            DayOfMonth    = d.Day;
            DayOfYear     = d.DayOfYear;
            Month         = d.Month;
            MonthName     = DateUtility.GetMonthName(d.Month);
            Year          = d.Year;

            PersianDate          = j.ToShortDateString();
            PersianDateInt       = j.ToShortDateInt();
            PersianLongDate      = j.ToLongDateString();
            PersianDayOfWeek     = (int)j.PersianDayOfWeek + 1;
            PersianDayOfWeekName = j.GetLongDayOfWeekName;
            PersianDayOfMonth    = j.Day;
            PersianDayOfYear     = j.GetDayOfYear;
            PersianWeekOfMonth   = j.GetWeekOfMonth;
            PersianWeekOfYear    = j.GetWeekOfYear;
            PersianMonth         = j.Month;
            PersianMonthName     = j.MonthName;
            PersianQuarter       = DateUtility.GetQuarter(j.Month);
            PersianQuarterName   = DateUtility.GetPersinQuarterName(PersianQuarter);
            PersianHalfYear      = DateUtility.GetHalfYear(j.Month);
            PersianHalfYearName  = DateUtility.GetPersianHalfYearName(PersianHalfYear);
            PersianYear          = j.Year;
            PersianIsLeapYear    = j.IsLeapYear;
        }
Beispiel #2
0
        public IEnumerable <Food> CreateUnknownFoods(DateTime startOfWeek)
        {
            var dateInPersian  = new PersianDateTime(startOfWeek).AddDays(-1);
            var dateInGeorgian = startOfWeek.AddDays(-1);

            List <Food> result = new List <Food>();

            for (int i = 0; i < 5; i++)
            {
                dateInPersian  = dateInPersian.AddDays(+1);
                dateInGeorgian = dateInGeorgian.AddDays(+1);

                var newFood = new Food()
                {
                    Date        = dateInGeorgian,
                    PersianDate = dateInPersian.ToShortDateInt(),
                };

                result.Add(newFood);
            }

            _foodRepository.Insert(result.ToArray());
            return(result);
        }