コード例 #1
0
        public ActionResult EnrollCourse(Enroll aEnroll)
        {
            EnrollManager  aEnrollManager  = new EnrollManager();
            StudentManager aStudentManager = new StudentManager();

            ViewBag.studentlist = aStudentManager.GetAllStudents();
            var courselist = aEnrollManager.GetAllEnrollsByRegNo(aEnroll.StudentRegNo);
            var check      = courselist.FirstOrDefault(a => a.CourseId == aEnroll.CourseId);

            var courselisttrue = aEnrollManager.GetAllEnrollsByRegNoTrue(aEnroll.StudentRegNo);
            var checktrue      = courselisttrue.FirstOrDefault(a => a.CourseId == aEnroll.CourseId);

            if (aEnroll.CourseId == 0)
            {
                ViewBag.message = "Select Course";
            }
            else
            {
                if (checktrue != null)
                {
                    ViewBag.message = "This Course Already Assigned";
                }
                else
                {
                    aEnrollManager.EnrollCourse(aEnroll);
                    ViewBag.message = "Course Enrolled Successfully";
                }
            }

            return(View(aEnroll));
        }
 public ActionResult EnrollCourse(Enroll enroll)
 {
     if (ModelState.IsValid)
     {
         ViewBag.message = enrollManager.EnrollCourse(enroll);
     }
     ViewBag.RegNo = enrollManager.GetAllRegNoForDropdown();
     return(View());
 }