Exemple #1
0
 public void ForbiddenResource()
 {
     using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
     {
         Assert.IsNull(repo.GetPeriodById(1, manager.FindByEmail("*****@*****.**").Id));
     }
 }
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));
        }