示例#1
0
        /// <summary>
        /// View an experience as an instructor
        /// NOTE: Instructor must have acccess to the experience AND the experience must have instructorViewable = true
        /// </summary>
        /// <param name="id">Experience Id</param>
        /// <param name="notificationId">Notification to show along with experience</param>
        /// <returns></returns>
        public ActionResult ViewExperience(Guid id, Guid? notificationId)
        {
            var experience =
                RepositoryFactory.ExperienceRepository.Queryable.SingleOrDefault(x => x.Id == id &&
                                                                                      x.Instructors.Any(i => i.Identifier == CurrentUser.Identity.Name));

            if (experience == null)
            {
                return new HttpNotFoundResult();
            }
            if (experience.InstructorViewable == false)
            {
                return new HttpUnauthorizedResult();
            }

            var notification = notificationId.HasValue == false
                                   ? null
                                   : RepositoryFactory.FeedbackRequestRepository.Queryable.SingleOrDefault(
                                       x =>
                                       x.Id == notificationId.Value &&
                                       x.Instructor.Identifier == CurrentUser.Identity.Name);

            var model = new ExperienceViewModel
                {
                    Experience = experience,
                    Notification = notification,
                    SupportingWorks = experience.SupportingWorks.ToList(),
                    ExperienceOutcomes = experience.ExperienceOutcomes.ToList()
                };

            return View(model);
        }
示例#2
0
        public ActionResult ViewExperience(Guid id)
        {
            var experience =
                RepositoryFactory.ExperienceRepository.Queryable.SingleOrDefault(
                    x => x.Id == id && x.Creator.Identifier == CurrentUser.Identity.Name);

            if (experience == null)
            {
                return new HttpNotFoundResult("Could not find the requested experience");
            }

            var model = new ExperienceViewModel
                {
                    Experience = experience,
                    SupportingWorks = experience.SupportingWorks.ToList(),
                    ExperienceOutcomes = experience.ExperienceOutcomes.ToList(),
                    Instructors = new MultiSelectList(RepositoryFactory.InstructorRepository.Queryable.OrderBy(x=>x.LastName).ToList(), "Id", "DisplayName"),
                    Outcomes = new SelectList(RepositoryFactory.OutcomeRepository.Queryable.OrderBy(x=>x.Name), "Id", "Name"),
                    Feedback = experience.FeedbackRequests.Where(x=>x.ResponseDate != null).ToList()
                };

            return View(model);
        }