Пример #1
0
 public ActionResult Details(int id)
 {
     using (EnrollmentsManager)
     {
         using (StudManager)
         {
             using (PeopleManager)
             {
                 using (CoursesManager)
                 {
                     using (SemestersManager)
                     {
                         var disp = Mapper.Map <vmEnrollment>(EnrollmentsManager.GetEnrollmentbyID(id));
                         if (disp != null)
                         {
                             disp.Student        = Mapper.Map <vmStudent>(StudManager.GetStudentbyID(disp.StudentID));
                             disp.Student.Person = Mapper.Map <vmPerson>(PeopleManager.GetPersonbyID(disp.Student.PersonID));
                             disp.Course         = Mapper.Map <vmCourse>(CoursesManager.GetCoursebyID(disp.CourseID));
                             disp.Semester       = Mapper.Map <vmSemester>(SemestersManager.GetSemesterbyID(disp.SemesterID));
                         }
                         else
                         {
                             disp = new vmEnrollment();
                             ModelState.AddModelError("", "Failed to load details for requested object");
                         }
                         return(View(disp));
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 public ActionResult Delete(vmEnrollment enroll)
 {
     try
     {
         using (EnrollmentsManager)
         {
             var item    = EnrollmentsManager.GetEnrollmentbyID(enroll.ID);
             var success = EnrollmentsManager.RemoveEnrollment(item);
             if (success)
             {
                 return(RedirectToAction("Index"));
             }
             throw new DataException("Enable to delete enrollment # " + enroll.ID + ". Please try again.");
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(enroll));
 }
Пример #3
0
 public ActionResult Edit(vmEnrollment enroll)
 {
     try
     {
         using (EnrollmentsManager)
         {
             var item = EnrollmentsManager.GetEnrollmentbyID(enroll.ID);
             item.Grade = enroll.Grade;
             var success = EnrollmentsManager.UpdateEnrollment(item);
             if (success)
             {
                 return(RedirectToAction("Index"));
             }
             throw new DataException("Failed to save enrollment #" + enroll.ID + ". Please try again");
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(enroll));
 }