Exemplo n.º 1
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));
                     }
                 }
             }
         }
     }
 }
 public HttpResponseMessage GetAllEnrollments()
 {
     HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError);
     try
     {
         EnrollmentsManager enrollManager = new EnrollmentsManager();
         List<EnrollmentEntity> enrollments = enrollManager.GetAllEnrollments();
         response = Request.CreateResponse(HttpStatusCode.OK, enrollments);
     }
     catch (Exception ex)
     {
         response.Content = new StringContent($"{GENERIC_ERROR}  [{ex.Message}]");
         DbLog.LogError("Error in EnrollmentsController", ex);
     }
     return response;
 }