public static EmailTemplateListViewModel Create(IRepository repository, int? templateId, int? callForProposalId)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new EmailTemplateListViewModel();

            if (templateId != null  && templateId != 0)
            {
                viewModel.IsTemplate = true;
                viewModel.EmailTemplateList = repository.OfType<EmailTemplate>().Queryable.Where(a => a.Template != null && a.Template.Id == templateId);
                viewModel.TemplateId = templateId;
            }
            else if (callForProposalId != null && callForProposalId != 0)
            {
                viewModel.IsCallForProposal = true;
                viewModel.EmailTemplateList = repository.OfType<EmailTemplate>().Queryable.Where(a => a.CallForProposal != null && a.CallForProposal.Id == callForProposalId);
                viewModel.CallForProposalId = callForProposalId;
            }
            viewModel.DescriptionDict = new Dictionary<EmailTemplateType, string>(7);
            viewModel.DescriptionDict.Add(EmailTemplateType.InitialCall, StaticValues.InitialCall);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalApproved, StaticValues.ProposalApproved);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalConfirmation, StaticValues.ProposalConfirmation);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalDenied, StaticValues.ProposalDenied);
            viewModel.DescriptionDict.Add(EmailTemplateType.ReadyForReview, StaticValues.ReadyForReview);
            viewModel.DescriptionDict.Add(EmailTemplateType.ReminderCallIsAboutToClose, StaticValues.ReminderCallIsAboutToClose);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalUnsubmitted, StaticValues.ProposalUnsubmitted);

            return viewModel;
        }
Example #2
0
        public static QuestionViewModel Create(IRepository repository, int? templateId, int? callForProposalId)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new QuestionViewModel
            {
                Question = new Question(),
                QuestionTypes = repository.OfType<QuestionType>().GetAll(),
                Validators = repository.OfType<Validator>().GetAll()
            };

            if (templateId != null && templateId != 0)
            {
                viewModel.IsTemplate = true;
                viewModel.TemplateId = templateId;
            }
            else if (callForProposalId != null && callForProposalId != 0)
            {
                viewModel.IsCallForProposal = true;
                viewModel.CallForProposalId = callForProposalId;
            }

            Check.Require(viewModel.IsTemplate || viewModel.IsCallForProposal, "Must have either a template or a call for proposal");

            return viewModel;
        }
Example #3
0
        public static QuestionViewModel Create(IRepository repository)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new QuestionViewModel()
            {
                QuestionTypes = repository.OfType<QuestionType>().GetAll(),
                Validators = repository.OfType<Validator>().GetAll()
            };

            return viewModel;
        }
        public static WorkgroupAccountModel Create(IRepository repository, Workgroup workgroup, WorkgroupAccount workgroupAccount = null)
        {
            Check.Require(repository != null, "repo null");
            Check.Require(workgroup != null, "workgroup null");

            var viewModel = new WorkgroupAccountModel { Workgroup = workgroup, WorkgroupAccount = workgroupAccount ?? new WorkgroupAccount()};

            viewModel.WorkGroupPermissions = repository.OfType<WorkgroupPermission>().Queryable.Where(a => a.Workgroup == workgroup && (!a.IsAdmin || (a.IsAdmin && a.IsFullFeatured))).ToList();
            viewModel.Accounts = workgroup.Organizations.SelectMany(x => x.Accounts).Distinct().ToList();

            viewModel.Approvers = viewModel.WorkGroupPermissions.Where(x => x.Role.Id == Role.Codes.Approver).Select(x => x.User).Distinct().ToList();
            viewModel.AccountManagers = viewModel.WorkGroupPermissions.Where(x => x.Role.Id == Role.Codes.AccountManager).Select(x => x.User).Distinct().ToList();
            viewModel.Purchasers = viewModel.WorkGroupPermissions.Where(x => x.Role.Id == Role.Codes.Purchaser).Select(x => x.User).Distinct().ToList();

            if (viewModel.WorkgroupAccount.Approver == null)
            {
                var approver = repository.OfType<WorkgroupPermission>().Queryable.SingleOrDefault(
                        a =>
                        a.Workgroup == workgroup && a.Role.Id == Role.Codes.Approver && !a.IsAdmin &&
                        a.IsDefaultForAccount);
                if (approver != null)
                {
                    viewModel.WorkgroupAccount.Approver = approver.User;
                }
            }

            if (viewModel.WorkgroupAccount.AccountManager == null)
            {
                var approver = repository.OfType<WorkgroupPermission>().Queryable.SingleOrDefault(
                        a =>
                        a.Workgroup == workgroup && a.Role.Id == Role.Codes.AccountManager && !a.IsAdmin &&
                        a.IsDefaultForAccount);
                if (approver != null)
                {
                    viewModel.WorkgroupAccount.AccountManager = approver.User;
                }
            }

            if (viewModel.WorkgroupAccount.Purchaser == null)
            {
                var approver = repository.OfType<WorkgroupPermission>().Queryable.SingleOrDefault(
                        a =>
                        a.Workgroup == workgroup && a.Role.Id == Role.Codes.Purchaser && !a.IsAdmin &&
                        a.IsDefaultForAccount);
                if (approver != null)
                {
                    viewModel.WorkgroupAccount.Purchaser = approver.User;
                }
            }

            return viewModel;
        }
        public static AdminRegisterForStudentViewModel Create(IRepository repository, RegistrationModel registrationModel)
        {
            Check.Require(repository != null, "Repository is required.");
            Check.Require(registrationModel != null, "registrationModel is required.");

            var viewModel = new AdminRegisterForStudentViewModel()
            {
                RegistrationModel = registrationModel,
                Majors = repository.OfType<MajorCode>().GetAll(),
                Ceremonies = repository.OfType<Ceremony>().Queryable.Where(a=>a.TermCode == TermService.GetCurrent()).ToList(),
            };

            return viewModel;
        }
        public static void BeginReportRequest(IRepository repository, HonorsPostModel honorsModel, string userId)
        {
            var parameters = new Dictionary<string, string>();
            var reportName = "/Commencement/Honors";

            parameters.Add("CollegeId", honorsModel.College.Id);
            parameters.Add("TermCode", honorsModel.TermCode);
            parameters.Add("Honors4590", honorsModel.Honors4590.ToString());
            parameters.Add("HighHonors4590", honorsModel.HighHonors4590.ToString());
            parameters.Add("HighestHonors4590", honorsModel.HighestHonors4590.ToString());
            parameters.Add("Honors90135", honorsModel.Honors90135.ToString());
            parameters.Add("HighHonors90135", honorsModel.HighHonors90135.ToString());
            parameters.Add("HighestHonors90135", honorsModel.HighestHonors90135.ToString());
            parameters.Add("Honors135", honorsModel.Honors135.ToString());
            parameters.Add("HighHonors135", honorsModel.HighHonors135.ToString());
            parameters.Add("HighestHonors135", honorsModel.HighestHonors135.ToString());

            var hr = honorsModel.Convert();
            hr.User = repository.OfType<vUser>().Queryable.FirstOrDefault(a => a.LoginId == userId);

            // start the transaction just so we can record the request
            using (var ts = new TransactionScope())
            {
                // create the history object, plus this will also set the request date time
                repository.OfType<HonorsReport>().EnsurePersistent(hr);
                ts.CommitTransaction();
            }

            // make the call to get the report, then save it and email the user
            using (var ts = new TransactionScope())
            {
                // get the actual report itself
                hr.Contents = GetHonorsReport(parameters); //Get(reportName, parameters);

                // persist the object
                repository.OfType<HonorsReport>().EnsurePersistent(hr);
                ts.CommitTransaction();

                // email the user
                //var message = new MailMessage();
                //message.To.Add(hr.User.Email);
                //message.Subject = "Commencement - Honors Report Completed";
                //message.Body = "Your honors report request has completed.";
                //message.IsBodyHtml = true;

                //// settings are set in the web.config
                //var client = new SmtpClient();
                //client.Send(message);
            }
        }
Example #7
0
        public static RequirementViewModel Create(IRepository repository, Project project)
        {
            Check.Require(repository != null, "Repository must be supplied");
            Check.Require(project != null, "project is required.");

            var viewModel = new RequirementViewModel
                                {
                                    Requirement = new Requirement(),
                                    Project = project,
                                    RequirementTypes = repository.OfType<RequirementType>().GetAll(),
                                    PriorityTypes = repository.OfType<PriorityType>().GetAll(),
                                    RequirementCategories = project.RequirementCategories.Where(a => a.IsActive).ToList()
                                };

            return viewModel;
        }
Example #8
0
        public static AddEditorViewModel Create(IRepository repository, Template template, CallForProposal callForProposal)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new AddEditorViewModel()
            {
                Template = template,
                CallForProposal = callForProposal,
                Users = repository.OfType<User>().Queryable.OrderBy(a => a.LastName).ToList()
            };
            if (template != null)
            {
                viewModel.IsTemplate = true;
                viewModel.TemplateId = template.Id;
            }
            else if (callForProposal != null)
            {
                viewModel.IsCallForProposal = true;
                viewModel.CallForProposalId = callForProposal.Id;
            }

            Check.Require(viewModel.IsTemplate || viewModel.IsCallForProposal, "Must have either a template or a call for proposal");

            return viewModel;
        }
        public static AdminExtraTicketPetitionViewModel Create(IRepository repository, ICeremonyService ceremonyService, IPetitionService petitionService, IPrincipal currentUser, TermCode termCode, int? ceremonyId, bool? viewAll)
        {
            Check.Require(repository != null, "Repository is required.");

            // set the default to false
            viewAll = viewAll ?? false;

            var ceremonies = ceremonyService.GetCeremonies(currentUser.Identity.Name, termCode);
            //var ceremonyIds = ceremonies.Select(a => a.Id).ToList();

            var viewModel = new AdminExtraTicketPetitionViewModel()
                                {
                                    Ceremonies = ceremonies,
                                    Ceremony = ceremonyId.HasValue ? repository.OfType<Ceremony>().GetNullableById(ceremonyId.Value) : null,
                                    ViewAll = viewAll.Value
                                };

            // has a ceremony been selected and does the current user have access
            if (ceremonyId.HasValue && ceremonyService.HasAccess(ceremonyId.Value, currentUser.Identity.Name))
            {
                if (viewAll.Value)
                {
                    viewModel.RegistrationParticipations = viewModel.Ceremony.RegistrationParticipations.Where(a => a.ExtraTicketPetition != null).ToList();
                }
                else
                {
                    viewModel.RegistrationParticipations = petitionService.GetPendingExtraTicket(currentUser.Identity.Name, ceremonyId.Value, termCode);
                }

            }

            return viewModel;
        }
Example #10
0
        public static EmailQueueListViewModel Create(IRepository repository, CallForProposal callForProposal)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new EmailQueueListViewModel{CallForProposal = callForProposal};
            viewModel.EmailQueues = repository.OfType<EmailQueue>().Queryable.Where(a => a.CallForProposal == callForProposal);

            return viewModel;
        }
        public static ActiveSurveyViewModel Create(IRepository repository, bool isPublic)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new ActiveSurveyViewModel { IsPublic = isPublic};
            viewModel.Surveys = repository.OfType<Survey>().Queryable.Where(a => a.IsActive);

            return viewModel;
        }
Example #12
0
        public static EmailsForCallSendViewModel Create(IRepository repository, CallForProposal callForProposal)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new EmailsForCallSendViewModel {CallForProposal = callForProposal, Immediate = false};

            viewModel.EmailsForCallList = repository.OfType<EmailsForCall>().Queryable.Where(a => a.CallForProposal != null && a.CallForProposal == callForProposal);

            return viewModel;
        }
        public static AdminStudentViewModel Create(IRepository repository, IMajorService majorService, ICeremonyService ceremonyService, TermCode termCode, string studentid, string lastName, string firstName, string majorCode, string college, string userId)
        {
            Check.Require(repository != null, "Repository is required.");

            // build a list of majors that the current user has assigned to their ceremonies
            var ceremonies = ceremonyService.GetCeremonies(userId, TermService.GetCurrent());
            var majors = ceremonies.SelectMany(a => a.Majors).Where(a => a.ConsolidationMajor == null && a.IsActive).ToList();
            var colleges = ceremonies.SelectMany(a => a.Colleges).Distinct().ToList();

            var viewModel = new AdminStudentViewModel()
                                {
                                    MajorCodes = majors,
                                    studentidFilter = studentid,
                                    lastNameFilter = lastName,
                                    firstNameFilter = firstName,
                                    majorCodeFilter = majorCode,
                                    Colleges = colleges
                                };

            var query = repository.OfType<Student>().Queryable.Where(a =>
                    a.TermCode == termCode
                    && (a.StudentId.Contains(string.IsNullOrEmpty(studentid) ? string.Empty : studentid.Trim()))
                    && (a.LastName.Contains(string.IsNullOrEmpty(lastName) ? string.Empty : lastName.Trim()))
                    && (a.FirstName.Contains(string.IsNullOrEmpty(firstName) ? string.Empty : firstName.Trim()))
                    );

            // get the list of students with optional filters
            var students = query.ToList();

            if (colleges.Count == 1)
            {
                var coll = colleges.First();
                students = students.Where(a => a.StrColleges.Contains(coll.Id)).ToList();
            }

            if (!string.IsNullOrEmpty(majorCode)) students = students.Where(a => a.StrMajorCodes.Contains(majorCode)).ToList();
            if (!string.IsNullOrEmpty(college)) students = students.Where(a => a.StrColleges.Contains(college)).ToList();

            // get all active registrations
            var reg = repository.OfType<RegistrationParticipation>().Queryable.Where(
                    a => a.Ceremony.TermCode == termCode).// && !a.Registration.Student.SjaBlock && !a.Registration.Cancelled).
                    ToList();

            var regStudents = reg.Select(a => a.Registration.Student);

            viewModel.StudentRegistrationModels = new List<StudentRegistrationModel>();

            foreach(var s in students.Distinct().ToList())
            {
                var reged = regStudents.Any(a => a == s);

                viewModel.StudentRegistrationModels.Add(new StudentRegistrationModel(s, reged));
            }

            return viewModel;
        }
Example #14
0
        public static CreateReportViewModel Create(IRepository repository, Item item)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new CreateReportViewModel() {Item = item};
            viewModel.QuestionTypeNoAnswer =
                repository.OfType<QuestionType>().Queryable.Where(a => a.Name == QuestionTypeText.STR_NoAnswer).
                    FirstOrDefault();

            return viewModel;
        }
Example #15
0
        public static MyTasksViewModel Create(IRepository repository, string loginId)
        {
            Check.Require(repository != null, "repository is required.");

            var tasks = repository.OfType<Task>().Queryable.Where(a => a.Worker.LoginId == loginId && !a.Complete);
            var projects = tasks.Where(a => !a.Complete ).Select(a => a.Project).Distinct();

            var viewModel = new MyTasksViewModel() {Tasks = tasks, Projects = projects};

            return viewModel;
        }
        public static TransferRequestViewModel Create(IRepository repository, RegistrationParticipation registrationParticipation, string username, TransferRequest transferRequest = null)
        {
            var viewModel = new TransferRequestViewModel()
                {
                    Ceremonies = repository.OfType<Ceremony>().Queryable.Where(a => a.TermCode == TermService.GetCurrent()),
                    RegistrationParticipation = registrationParticipation,
                    TransferRequest = transferRequest ?? new TransferRequest()
                };

            return viewModel;
        }
Example #17
0
        public static QuestionSetLinkViewModel Create(IRepository repository, string loginId)
        {
            Check.Require(repository != null, "Repository is required.");

            // get the user's colleges
            var user = repository.OfType<User>().Queryable.Where(x => x.LoginID == loginId).FirstOrDefault();
            var colleges = (from x in user.Units
                            select x.School).ToList();

            var query = from x in repository.OfType<QuestionSet>().Queryable
                        where (x.SystemReusable
                            || colleges.Contains(x.School)
                            || x.UserReusable && x.User.LoginID == loginId)
                            && x.Name != StaticValues.QuestionSet_ContactInformation
                        select x;

            var viewModel = new QuestionSetLinkViewModel() { QuestionSets = query };

            return viewModel;
        }
Example #18
0
        public static EmailsForCallListViewModel Create(IRepository repository, int? templateId, int? callForProposalId)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new EmailsForCallListViewModel();

            if (templateId != null && templateId != 0)
            {
                viewModel.IsTemplate = true;
                viewModel.EmailsForCallList = repository.OfType<EmailsForCall>().Queryable.Where(a => a.Template != null && a.Template.Id == templateId);
                viewModel.TemplateId = templateId;
            }
            else if (callForProposalId != null && callForProposalId != 0)
            {
                viewModel.IsCallForProposal = true;
                viewModel.EmailsForCallList = repository.OfType<EmailsForCall>().Queryable.Where(a => a.CallForProposal != null && a.CallForProposal.Id == callForProposalId);
                viewModel.CallForProposalId = callForProposalId;
            }

            return viewModel;
        }
Example #19
0
        public static TermcodeViewModel Create(IRepository Repository)
        {
            var viewModel = new TermcodeViewModel();

            var termCodes = Repository.OfType<TermCode>().Queryable.OrderByDescending(a => a.IsActive).ThenBy(a => a.Id);
            viewModel.AllTermCodes = termCodes.Select(a => new TermCodeUnion {IsActive = a.IsActive, IsInTermCode = true, Name = a.Name, TermCodeId = a.Id, RegistrationBegin = a.RegistrationBegin, RegistrationDeadline = a.RegistrationDeadline}).ToList();

            viewModel.VTermCodes = Repository.OfType<vTermCode>().Queryable.Where(a => a.StartDate >= DateTime.UtcNow.ToPacificTime()) .ToList();
            var count = 0;
            foreach (var vTermCode in viewModel.VTermCodes.Where(vTermCode => !viewModel.AllTermCodes.AsQueryable().Where(a => a.TermCodeId == vTermCode.Id).Any()))
            {
                viewModel.AllTermCodes.Add(new TermCodeUnion(){IsActive = false, IsInTermCode = false, Name = vTermCode.Description, TermCodeId = vTermCode.Id});
                count++;
                if (count >= 3)
                {
                    break;
                }
            }

            return viewModel;
        }
        public static EmailStudentsViewModel Create(IRepository repository, ICeremonyService ceremonyService, string userId, List<string> templateNames )
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new EmailStudentsViewModel()
                                {
                                    Ceremonies = ceremonyService.GetCeremonies(userId, TermService.GetCurrent()),
                                    TemplateTypes = repository.OfType<TemplateType>().Queryable.Where(a => templateNames.Contains(a.Name)).ToList()
                                };

            return viewModel;
        }
Example #21
0
        public static ExtendedPropertyViewModel Create(IRepository repository, ItemType itemType)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new ExtendedPropertyViewModel()
                                {
                                    QuestionTypes = repository.OfType<QuestionType>().Queryable.Where(a => a.ExtendedProperty).ToList(),
                                    ItemType = itemType
                                };

            return viewModel;
        }
        public static AddEditorViewModel Create(IRepository repository, Ceremony ceremony)
        {
            Check.Require(repository != null, "Repository is required.");
            Check.Require(ceremony != null, "ceremony is required.");

            var viewModel = new AddEditorViewModel()
                                {
                                    Ceremony = ceremony,
                                    Users = repository.OfType<vUser>().Queryable.OrderBy(a => a.LastName).ToList()
                                };

            return viewModel;
        }
        public static NotificationTrackingViewModel Create(IRepository repository, string siteId, NotificationTracking notificationTracking = null, Person person = null, MailingList mailingList = null)
        {
            Check.Require(repository != null, "Repository is required.");

            var seminar = SiteService.GetLatestSeminar(siteId);

            var viewModel = new NotificationTrackingViewModel(){
                                    NotificationTracking = notificationTracking ?? new NotificationTracking(),
                                    NotificationMethods = repository.OfType<NotificationMethod>().GetAll(),
                                    NotificationTypes = repository.OfType<NotificationType>().GetAll(),
                                    People = new List<Person>(),
                                    AllPeople = SiteService.GetLatestSeminar(siteId).SeminarPeople.Select(a => a.Person).ToList(),//seminarService.GetCurrent().SeminarPeople.Select(a=>a.Person).ToList(),
                                    SitePeople = SiteService.LoadSite(siteId).People,
                                    Seminar = seminar,
                                    MailingLists = seminar.MailingLists,
                                    MailingList = mailingList
                                };

            if (person != null) viewModel.People.Add(person);

            return viewModel;
        }
        public static AdminEditStudentViewModel Create(IRepository repository, ICeremonyService ceremonyService, Student student, string userId)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new AdminEditStudentViewModel()
                                {
                                    Student = student,
                                    Majors = repository.OfType<MajorCode>().Queryable.Where(a => a.IsActive).OrderBy(a => a.Name).ToList(),
                                    Ceremonies = ceremonyService.GetCeremonies(userId, TermService.GetCurrent())
                                };

            return viewModel;
        }
Example #25
0
        public static TemplateCreateViewModel Create(IRepository repository, Template template, Ceremony ceremony)
        {
            Check.Require(repository != null, "Repository is required.");
            Check.Require(ceremony != null, "ceremony is required.");

            var viewModel = new TemplateCreateViewModel()
                                {
                                    TemplateTypes = repository.OfType<TemplateType>().Queryable.OrderBy(a => a.Name),
                                    Template = template,
                                    Ceremony = ceremony
                                };

            return viewModel;
        }
Example #26
0
        public static ProjectViewModel Create(IRepository repository, string login)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var worker = repository.OfType<Worker>().Queryable.Where(a => a.LoginId == login).First();

            var viewModel = new ProjectViewModel {
                Project = new Project(),
                StatusCodes = repository.OfType<StatusCode>().GetAll(),
                ProjectTypes = repository.OfType<ProjectType>().Queryable.Where(a=>a.IsActive).OrderBy(a=>a.Order).ToList(),
                PriorityTypes = repository.OfType<PriorityType>().Queryable.OrderBy(a=>a.Order).ToList(),
                Workgroups = worker.WorkgroupWorkers.Where(a=>a.Workgroup.IsActive).Select(a=>a.Workgroup).ToList(),
            };

            var workers = new List<Worker>();
            foreach (var a in viewModel.Workgroups)
            {
                workers.AddRange(a.WorkgroupWorkers.Select(b=>b.Worker).ToList());
            }
            viewModel.Workers = workers.Distinct().OrderBy(a => a.LastName).ToList();

            return viewModel;
        }
        public static ChangeCeremonyViewModel Create(IRepository repository, Registration registration)
        {
            Check.Require(repository != null, "Repository is not required.");
            Check.Require(registration != null, "Registration is not required.");

            var viewModel = new ChangeCeremonyViewModel()
                                {
                                    Ceremonies = repository.OfType<Ceremony>().Queryable.Where(a=>a.TermCode == TermService.GetCurrent()),
                                    Student = registration.Student,
                                    Registration = registration
                                };

            return viewModel;
        }
Example #28
0
        public static HelpTopicViewModel Create(IRepository repository, IPrincipal currentUser)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new HelpTopicViewModel();
            viewModel.IsUserAuthorized = currentUser.IsInRole(RoleNames.Admin) || currentUser.IsInRole(RoleNames.User);
            viewModel.IsUserAdmin = currentUser.IsInRole(RoleNames.Admin);

            if(viewModel.IsUserAdmin)
            {
                viewModel.HelpTopics = repository.OfType<HelpTopic>().Queryable;
            }
            else if(viewModel.IsUserAuthorized)
            {
                viewModel.HelpTopics = repository.OfType<HelpTopic>().Queryable.Where(a => a.IsActive);
            }
            else
            {
                viewModel.HelpTopics = repository.OfType<HelpTopic>().Queryable.Where(a => a.AvailableToPublic && a.IsActive).OrderByDescending(a => a.NumberOfReads);
            }

            return viewModel;
        }
Example #29
0
        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 SessionPersonViewModel Create(IRepository repository, Session session, SeminarPerson seminarPerson = null)
        {
            Check.Require(repository != null, "Repository is required.");

            var seminar = repository.OfType<Seminar>().GetNullableById(session.Seminar.Id);

            var viewModel = new SessionPersonViewModel()
                                {
                                    SeminarPeople = seminar.SeminarPeople,
                                    Session = session,
                                    SeminarPerson = seminarPerson ?? new SeminarPerson()
                                };

            return viewModel;
        }