Ejemplo n.º 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));
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            using (EnrollmentsManager)
            {
                using (CoursesManager)
                {
                    using (StudManager)
                    {
                        using (PeopleManager)
                        {
                            using (SemestersManager)
                            {
                                var disp = new vmEnrollment();
                                disp.Courses   = CoursesManager.GetAllCourses().ToList();
                                disp.Semesters = SemestersManager.GetAllSemesters().ToList();
                                var students = StudManager.GetAllStudents();
                                var people   = PeopleManager.GetAllPeople();

                                var studs = from student in students
                                            join person in people on student.PersonID equals person.ID
                                            select new KeyValuePair <int, string>(student.ID, string.Format("{0}, {1}", person.LastName, person.FirstMidName));
                                disp.Students = studs.ToDictionary(t => t.Key, t => t.Value);
                                return(View(disp));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
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));
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 public ActionResult Index()
 {
     using (SemestersManager)
     {
         var disp = Mapper.Map <IEnumerable <vmSemester> >(SemestersManager.GetAllSemesters());
         return(View(disp));
     }
 }
Ejemplo n.º 5
0
 public ActionResult Details(int id)
 {
     using (SemestersManager)
     {
         var disp = Mapper.Map <vmSemester>(SemestersManager.GetSemesterbyID(id));
         if (disp == null)
         {
             disp = new vmSemester();
             ModelState.AddModelError("", "Failed to load details for requested item.");
         }
         return(View(disp));
     }
 }
Ejemplo n.º 6
0
        public ActionResult Create(vmEnrollment enroll)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (EnrollmentsManager)
                    {
                        var item    = Mapper.Map <Enrollment>(enroll);
                        var success = EnrollmentsManager.AddEnrollment(item);
                        if (success)
                        {
                            return(RedirectToAction("Index"));
                        }
                        throw new DataException("Failed to save  enrollment #" + enroll.ID + ". Please try again");
                    }
                }
            }
            catch (DataException ex)
            {
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("", ex.Message);
            }
            using (EnrollmentsManager)
            {
                using (CoursesManager)
                {
                    using (StudManager)
                    {
                        using (PeopleManager)
                        {
                            using (SemestersManager)
                            {
                                enroll.Courses   = CoursesManager.GetAllCourses().ToList();
                                enroll.Semesters = SemestersManager.GetAllSemesters().ToList();
                                var students = StudManager.GetAllStudents();
                                var people   = PeopleManager.GetAllPeople();

                                var studs = from student in students
                                            join person in people on student.PersonID equals person.ID
                                            select new KeyValuePair <int, string>(student.ID, string.Format("{0}, {1}", person.LastName, person.FirstMidName));
                                enroll.Students = studs.ToDictionary(t => t.Key, t => t.Value);
                                return(View(enroll));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public ActionResult Create(vmSemester sem)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (SemestersManager)
             {
                 var item    = Mapper.Map <Semester>(sem);
                 var success = SemestersManager.AddSemester(item);
                 if (success)
                 {
                     return(RedirectToAction("Details", new { id = item.ID }));
                 }
                 throw new DataException("Unable to save Semester. Please try again.");
             }
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(sem));
 }