Пример #1
0
 private void calculateDaysTo(Holiday holiday)
 {
     int dayResult = holiday.Date.DayOfYear - DateTime.Now.DayOfYear;
     if (dayResult < 0)
         dayResult += 365;
     holiday.DaysTo = dayResult;
 }
Пример #2
0
        public Holiday CreateHoliday(EHolidayType holidayType)
        {
            Holiday holiday = new Holiday();

            switch(holidayType)
            {
                case EHolidayType.BOXING_DAY:
                    holiday.Name = "Boxing Day";
                    holiday.Date = DateTime.Parse("2016-12-26");
                    holiday.ImageFile = "boxingDay.jpg";
                    break;

                case EHolidayType.QUEENS_BIRTHDAY:
                    holiday.Name = "Queen's Birthday";
                    holiday.Date = DateTime.Parse("2016-6-06");
                    holiday.ImageFile = "queensBirthday.jpg";
                    break;

                case EHolidayType.HALLOWEEN:
                    holiday.Name = "Halloween";
                    holiday.Date = DateTime.Parse("2016-10-31");
                    holiday.ImageFile = "halloween.jpg";
                    break;
            }

            return holiday;
        }
Пример #3
0
        public ActionResult Index()
        {
            holidayFactory = new HolidayFactory();
            random = new Random();
            int rand = random.Next(HOLIDAYS);

            switch(rand)
            {
                case (int)EHolidayType.BOXING_DAY:
                    holiday = holidayFactory.CreateHoliday(EHolidayType.BOXING_DAY);
                    break;

                case (int)EHolidayType.HALLOWEEN:
                    holiday = holidayFactory.CreateHoliday(EHolidayType.HALLOWEEN);
                    break;

                case (int)EHolidayType.QUEENS_BIRTHDAY:
                    holiday = holidayFactory.CreateHoliday(EHolidayType.QUEENS_BIRTHDAY);
                    break;
            }
            calculateDaysTo(holiday);
            return View(holiday);
        }