コード例 #1
0
        public CalendarTimesViewModel getViewModel()
        {
            JewishCalendar cal = new JewishCalendar();
            //create the view model
            CalendarTimesViewModel vm = new CalendarTimesViewModel();
            DateTime date             = calModel.date.GetValueOrDefault();

            vm.DafYomiBavli         = cal.GetDafYomiBavli(date);
            vm.DayOfChanukah        = cal.GetDayOfChanukah(date);
            vm.DayOfOmer            = cal.GetDayOfOmer(date);
            vm.isChanukah           = cal.IsChanukah(date);
            vm.isCholHamoed         = cal.IsCholHamoed(date, calModel.isIsrael);
            vm.isErevRoshChodesh    = cal.IsErevRoshChodesh(date);
            vm.isErevYomTov         = cal.IsErevYomTov(date, calModel.isIsrael);
            vm.isRoshChodesh        = cal.IsRoshChodesh(date);
            vm.isTaanis             = cal.IsTaanis(date, calModel.isIsrael);
            vm.isYomTov             = cal.IsYomTov(date, calModel.isIsrael);
            vm.isYomTovIssurMelacha = cal.IsYomTovAssurBemelacha(date, calModel.isIsrael);
            vm.JewishHoliday        = cal.GetJewishHoliday(date, calModel.isIsrael);
            vm.JewishMonth          = cal.GetJewishMonth(date);
            vm.JewishYearType       = cal.GetJewishYearType(date);
            return(vm);
        }
コード例 #2
0
        public Object Index(String date, bool?isIsrael = null, String format = "json")
        {
            //verify that we received all of the parameters
            DateTime validDate;

            //if the date string cant be parsed then return that a valid date must be provided
            if (!DateTime.TryParse(date, out validDate))
            {
                return(Json("date is a required parameter, an example of a date is 2/2/14"));
            }
            //if is israel is null then return a message that its missing
            if (isIsrael is null)
            {
                return(Json("isIsrael is a required parameter, please specify true or false"));
            }
            //put the values in the model
            CalendarModel model = new CalendarModel();

            model.date     = validDate;
            model.isIsrael = isIsrael.GetValueOrDefault();
            //pass the model to the service to generate the calendar times
            CalendarService service = new CalendarService(model);
            //get a instance of the viewmodel to return
            CalendarTimesViewModel vm = service.getViewModel();

            //return the proper format based on the format param
            if (format == "json")
            {
                return(Json(vm));
            }
            else
            {
                //use xml serilization
                YAXSerializer serl = new YAXSerializer(vm.GetType());
                return(serl.Serialize(vm));
            }
        }