public ActionResult RequestFeedback(Guid id, string message, Guid[] instructors)
{
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 instructorsToNotify =
RepositoryFactory.InstructorRepository.Queryable.Where(x => instructors.Contains(x.Id)).ToList();
foreach (var instructor in instructorsToNotify)
{
experience.AddFeedbackRequest(new FeedbackRequest {Message = message, Instructor = instructor});
}
if (experience.InstructorViewable == false)
{
experience.InstructorViewable = true;
}
RepositoryFactory.ExperienceRepository.EnsurePersistent(experience);
Message = string.Format("Feedback Requests sent successfully");
return RedirectToAction("ViewExperience", "Student", new {id});
}