public ActionResult BySeminar(int id)
{
var seminar = _seminarRepository.GetNullableById(id);
// get the user's seminar person id
var user = _userRepository.Queryable.Where(a => a.LoweredUserName == CurrentUser.Identity.Name.ToLower()).SingleOrDefault();
if (user == null) return this.RedirectToAction<ErrorController>(a => a.NotAuthorized());
var person = user.Person;
var latestReg = person.GetLatestRegistration(Site);
if (seminar == null)
{
Message = string.Format(Messages.NotFound, "seminar", id);
return this.RedirectToAction<SeminarController>(a => a.MySeminar(latestReg.Id));
}
// validate seminar access
if (!_personService.HasAccess(person, seminar)) return this.RedirectToAction<ErrorController>(a => a.NotAuthorized());
ViewBag.seminarPersonId = latestReg.Id;
return View(seminar.CaseStudies);
}