示例#1
0
        public ActionResult Create(CourseDate lesson)
        {
            DateTime firstCourse = lessonB.FirstCourseDate(lesson.CourseID);

            try
            {
                if (ModelState.IsValid && (firstCourse == default(DateTime) || firstCourse == lesson.FirstCourse))
                {
                    lessonB.AddLesson(lesson);

                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            if (firstCourse != default(DateTime) && firstCourse != lesson.FirstCourse)
            {
                ModelState.AddModelError("", "This course already have first date course : " + firstCourse.ToString("d"));

                PopulateCourseDropDownList(lesson.CourseDateID);

                return(View(lesson));
            }

            PopulateCourseDropDownList(lesson.CourseDateID);

            return(View(lesson));
        }