public static AdminPersonViewModel Create(IRepository repository, IFirmService firmService, string siteId, int?seminarId, Person person = null, string email = null) { Check.Require(repository != null, "Repository is required."); var seminar = seminarId.HasValue ? repository.OfType <Seminar>().GetNullableById(seminarId.Value) : null; var viewModel = new AdminPersonViewModel() { PersonViewModel = PersonViewModel.Create(repository, firmService, siteId, seminar, person, email), SeminarRoles = repository.OfType <SeminarRole>().Queryable, RoomTypes = repository.OfType <RoomType>().Queryable.Where(a => a.IsActive), SeminarId = seminarId, Invited = SiteService.GetLatestSeminar(siteId).Invitations.Where(a => a.Person == person).Any(), SiteId = siteId }; // determine if last reg is the current seminar if (seminar != null) { viewModel.IsCurrentSeminar = seminar.Id == SiteService.GetLatestSeminar(siteId).Id; } return(viewModel); }
public static AdminPersonViewModel Create(IRepository repository, IFirmService firmService, string siteId, int? seminarId, Person person = null, string email = null) { Check.Require(repository != null, "Repository is required."); var seminar = seminarId.HasValue ? repository.OfType<Seminar>().GetNullableById(seminarId.Value) : null; var viewModel = new AdminPersonViewModel() { PersonViewModel = PersonViewModel.Create(repository, firmService, siteId, seminar, person, email), SeminarRoles = repository.OfType<SeminarRole>().Queryable, RoomTypes = repository.OfType<RoomType>().Queryable.Where(a=>a.IsActive), SeminarId = seminarId, Invited = SiteService.GetLatestSeminar(siteId).Invitations.Where(a => a.Person == person).Any(), SiteId = siteId }; // determine if last reg is the current seminar if (seminar != null) { viewModel.IsCurrentSeminar = seminar.Id == SiteService.GetLatestSeminar(siteId).Id; } return viewModel; }