Exemple #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));
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
 public ActionResult Index()
 {
     using (EnrollmentsManager)
     {
         using (CoursesManager)
         {
             using (StudManager)
             {
                 using (PeopleManager)
                 {
                     using (SemestersManager)
                     {
                         var disp = Mapper.Map <IEnumerable <vmEnrollment> >(EnrollmentsManager.GetAllEnrollments());
                         foreach (var d in disp)
                         {
                             d.Course         = Mapper.Map <vmCourse>(CoursesManager.GetCoursebyID(d.CourseID));
                             d.Student        = Mapper.Map <vmStudent>(StudManager.GetStudentbyID(d.StudentID));
                             d.Student.Person = Mapper.Map <vmPerson>(PeopleManager.GetPersonbyID(d.Student.PersonID));
                             d.Semester       = Mapper.Map <vmSemester>(SemestersManager.GetSemesterbyID(d.SemesterID));
                         }
                         return(View(disp));
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
 public ActionResult Edit(vmStudent student)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (PeopleManager)
             {
                 using (StudManager)
                 {
                     var person = PeopleManager.GetPersonbyID(student.PersonID);
                     person.FirstMidName = student.Person.FirstMidName;
                     person.LastName     = student.Person.LastName;
                     var success = PeopleManager.UpdatePerson(person);
                     if (success)
                     {
                         var stu = StudManager.GetStudentbyID(student.ID);
                         stu.EnrollmentDate = student.EnrollmentDate;
                         success            = StudManager.UpdateStudent(stu);
                         if (success)
                         {
                             return(RedirectToAction("Details", new { id = student.ID }));
                         }
                         else
                         {
                             throw new DataException("Unable to save Student. Please try again.");
                         }
                     }
                     else
                     {
                         throw new DataException("Unable to save person. Please try again.");
                     }
                 }
             }
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(student));
 }
Exemple #4
0
 public ActionResult Details(int id)
 {
     using (PeopleManager)
     {
         using (StudManager)
         {
             var item = StudManager.GetStudentbyID(id);
             var disp = Mapper.Map <vmStudent>(item);
             if (disp != null)
             {
                 disp.Person = Mapper.Map <vmPerson>(PeopleManager.GetPersonbyID(disp.PersonID));
             }
             else
             {
                 disp = new vmStudent();
                 ModelState.AddModelError("", "Failed to load details for requested item.");
             }
             return(View(disp));
         }
     }
 }
Exemple #5
0
 public ActionResult Delete(vmStudent student)
 {
     try
     {
         using (StudManager)
         {
             var stu     = StudManager.GetStudentbyID(student.ID);
             var success = StudManager.RemoveStudent(stu);
             if (success)
             {
                 return(RedirectToAction("Index"));
             }
             throw new DataException("Enable to delete intructor " + student.Person.FullName + ". Please try again.");
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(student));
 }