Exemple #1
0
        public ActionResult SaveResult(StudentResult aStudentResult)
        {
            StudentManager       aStudentManager       = new StudentManager();
            GradeManager         aGradeManager         = new GradeManager();
            StudentResultManager aStudentResultManager = new StudentResultManager();

            ViewBag.students = aStudentManager.GetAllStudents();
            ViewBag.gredes   = aGradeManager.GetAllGrades();
            var studentlist   = aStudentResultManager.GetAllStudentResultsByRegNo(aStudentResult.RegistrationNo);
            var studentcourse = studentlist.FirstOrDefault(s => s.CourseId == aStudentResult.CourseId);

            if (aStudentResult.CourseId == 0)
            {
                ViewBag.message = "Select Course";
            }
            else
            {
                if (studentcourse != null)
                {
                    ViewBag.message = "This Course Grade Already Exist";
                }
                else
                {
                    if (aStudentResultManager.SaveStudentResult(aStudentResult) > 0)
                    {
                        ViewBag.message = "Result Saved Successfully";
                    }
                    else
                    {
                        ViewBag.message = "Save Failed";
                    }
                }
            }

            return(View());
        }