Ejemplo n.º 1
0
        // GET: Student/OferringEnrollments
        public async Task <ActionResult> Index()
        {
            var currentTerm = await _termRepository.GetCurrentTerm();

            if (currentTerm == null)
            {
                AddPageAlerts(ViewHelpers.PageAlertType.Error, "There are no current term or it has not been selected yet.");

                return(RedirectToAction("Index", new { Controller = "Dashboard", Area = "" }));
            }

            var studentId = SessionHelper.User.UserId;

            var offeringsForCurrentTerm = _offeringRepository
                                          .GetOfferingsByTermId(currentTerm.Id.Value);

            var currentEnrollments = await _enrollmentRepository.
                                     GetEnrollmentsByStudentIdAndTermId(studentId, currentTerm.Id.Value);

            var isCurrentlyEnrolled = currentEnrollments.Count(e => !e.WithdropDate.HasValue) > 0;

            // Add properties to layout
            AddPageHeader("Enroll (Offerings)", "Enroll in an offering");

            AddBreadcrumb("Enroll (Offerings)", "");

            return(View(new OfferingEnrollmentListViewModel
            {
                Term = currentTerm,
                Offerings = offeringsForCurrentTerm,
                IsStudentCurrentlyEnrolled = isCurrentlyEnrolled
            }));
        }
Ejemplo n.º 2
0
        // GET: Admin/Offerings/View
        public async Task <ActionResult> View(int?termId)
        {
            if (!termId.HasValue)
            {
                return(HttpNotFound());
            }

            var term = await _termRepository.GetTermById(termId.Value);

            if (term == null)
            {
                return(HttpNotFound());
            }

            var offerings = _offeringRepository.GetOfferingsByTermId(termId.Value);

            // Add properties to layout
            AddPageHeader("Offerings (Terms)", "List of terms");

            AddBreadcrumb("Offerings (Terms)", Url.Action("Index"));
            AddBreadcrumb("Offerings (List)", "");

            return(View(new OfferingListViewModel
            {
                Term = term,
                Offerings = offerings
            }));
        }