Exemple #1
0
        // GET: Professor/Enrollments/ViewEvaluations
        public async Task <ActionResult> ViewEvaluations(int?enrollmentId)
        {
            if (!enrollmentId.HasValue)
            {
                return(HttpNotFound());
            }

            var enrollmentWithEvaluations = await _evaluationRepository.GetWithEvaluations(enrollmentId.Value);

            if (enrollmentWithEvaluations.Enrollment == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new EnrollmentWithEvaluationsViewModel(enrollmentWithEvaluations);

            // Add properties to layout
            AddPageHeader("Evaluations", "");

            AddBreadcrumb("Offerings (Terms)", Url.Action("Index"));
            AddBreadcrumb("Offerings (List)", Url.Action("ViewOfferings", new { TermId = viewModel.Enrollment.Offering.TermId }));
            AddBreadcrumb("Enrollments", Url.Action("ViewEnrollments", new { offeringId = viewModel.Enrollment.OfferingId }));
            AddBreadcrumb("Evaluations", "");

            return(View(viewModel));
        }
Exemple #2
0
        public async Task <ActionResult> SaveEvaluations(EnrollmentWithEvaluationsViewModel form)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var enrollmentWithEvaluations = await _evaluationRepository.GetWithEvaluations(form.Enrollment.Id);

                    enrollmentWithEvaluations.Enrollment.Notes = form.Enrollment.Notes;
                    enrollmentWithEvaluations.Evaluations      = form.Evaluations;

                    // Update enrollment
                    await _evaluationRepository.PutEnrollmentWithEvaluations(form.Enrollment.Id, enrollmentWithEvaluations);

                    AddPageAlerts(ViewHelpers.PageAlertType.Success, "Your changes have been saved succesfully.");

                    return(RedirectToAction("ViewEvaluations", new { enrollmentId = enrollmentWithEvaluations.Enrollment.Id }));
                }
                catch (BadRequestException bre)
                {
                    AddErrorsFromAdycHttpExceptionToModelState(bre, ModelState);
                }
            }

            form.Enrollment = await _enrollmentRepository.GetById(form.Enrollment.Id);

            foreach (var evaluation in form.Evaluations)
            {
                evaluation.Period = await _periodRepository.GetPeriodById(evaluation.PeriodId);
            }

            // Add properties to layout
            AddPageHeader("Evaluations", "");

            AddBreadcrumb("Offerings (Terms)", Url.Action("Index"));
            AddBreadcrumb("Offerings (List)", Url.Action("ViewOfferings", new { TermId = form.Enrollment.Offering.TermId }));
            AddBreadcrumb("Enrollments", Url.Action("ViewEnrollments", new { offeringId = form.Enrollment.OfferingId }));
            AddBreadcrumb("Evaluations", "");

            return(View("ViewEvaluations", form));
        }