コード例 #1
0
        public string CalculateReadyForSchool(DateTime birthdate)
        {
            DateTime       readyForSchool;
            SchoolHolidays schoolHolidays = new SchoolHolidays(birthdate);

            readyForSchool = schoolHolidays.CanGoToSchoolFrom();
            string date = readyForSchool.ToString("dd'/'MM'/'yyyy");

            return(date);
        }
コード例 #2
0
        public JsonResult CalculateReadyDateAJAX(string birthdate)
        {
            string format = "ddd MMM dd yyyy HH:mm:ss";

            if (string.IsNullOrEmpty(birthdate))
            {
                birthdate = birthdate.Substring(0, 24);

                DateTime birthdateDT;
                DateTime readyForSchool;
                DateTime readyForDaycare;

                birthdateDT = DateTime.ParseExact(birthdate, format, CultureInfo.InvariantCulture);
                //bool validFormat = DateTime.TryParseExact(birthdate, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out birthdateDT);
                //Console.Write(validFormat ? birthdateDT.ToString() : "Not a valid format");

                SchoolHolidays schoolHolidays = new SchoolHolidays(birthdateDT);

                readyForSchool = schoolHolidays.CanGoToSchoolFrom();

                // SETTINGOPTION!!!
                readyForDaycare = birthdateDT.AddMonths(2);

                var result = new { readyForSchool = readyForSchool.ToString("dd'/'MM'/'yyyy"), readyForDaycare = readyForDaycare.ToString("dd'/'MM'/'yyyy") };

                CreateAgreedDays_StartDate = readyForDaycare;
                CreateAgreedDays_EndDate   = readyForSchool;

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                string dateDaycare = CalculateReadyForDaycare(GetCurrentToddler().Person.BirthDate);
                string dateSchool  = CalculateReadyForSchool(GetCurrentToddler().Person.BirthDate);
                var    result      = new { readyForSchool = dateSchool, readyForDaycare = dateDaycare };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }