public CompletedLearningResourceViewModel(CompletedActionPlanResource resource) : base(resource) { LaunchResourceLink = resource.ResourceLink; ResourceDescription = resource.ResourceDescription; CatalogueName = resource.CatalogueName; ResourceType = DisplayStringHelper.AddSpacesToPascalCaseString(resource.ResourceType); ResourceReferenceId = resource.ResourceReferenceId; AbsentInLearningHub = resource.AbsentInLearningHub; }
/// <nodoc /> public ConvertException(Type[] expectedTypes, EvaluationResult value, ErrorContext errorContext, string errorDescription = null) : base(CreateDebugMessage(expectedTypes, value, errorDescription), errorContext) { Contract.Requires(expectedTypes != null); Contract.Requires(expectedTypes.Length > 0); ExpectedTypesToString = (context => DisplayStringHelper.UnionTypeToString(context, expectedTypes)); Value = value; }
public GroupDelegateViewModel(GroupDelegate groupDelegate) { GroupDelegateId = groupDelegate.GroupDelegateId; GroupId = groupDelegate.GroupId; DelegateId = groupDelegate.DelegateId; Name = DisplayStringHelper.GetDelegateNameString(groupDelegate.FirstName, groupDelegate.LastName); EmailAddress = groupDelegate.EmailAddress; CandidateNumber = groupDelegate.CandidateNumber; }
public ConfirmDelegateAddedViewModel(DelegateUser delegateUser, string groupName, int groupId) { DelegateName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( delegateUser.FirstName, delegateUser.LastName ); GroupName = groupName; GroupId = groupId; }
public ResourceViewModel(Resource resource, string currentSystemBaseUrl) { this.currentSystemBaseUrl = currentSystemBaseUrl; var fileNameParts = resource.FileName.Split('.'); Resource = $"{resource.Description} (.{fileNameParts.Last()})"; Date = resource.UploadDateTime.ToString(DateHelper.StandardDateFormat); Size = DisplayStringHelper.GenerateSizeDisplayString(resource.FileSize); downloadTag = resource.Tag; }
public ContractDetailsViewModel(List <AdminUser> adminUsers, Centre centreDetails, int numberOfCourses) { Administrators = adminUsers.Count(a => a.IsCentreAdmin).ToString(); Supervisors = adminUsers.Count(a => a.IsSupervisor).ToString(); var trainers = adminUsers.Count(a => a.IsTrainer); var cmsAdministrators = adminUsers.Count(a => a.IsCmsAdministrator); var cmsManagers = adminUsers.Count(a => a.IsCmsManager); var contentCreators = adminUsers.Count(a => a.IsContentCreator); Trainers = DisplayStringHelper.FormatNumberWithLimit(trainers, centreDetails.TrainerSpots); TrainersColour = DisplayColourHelper.GetDisplayColourForPercentage(trainers, centreDetails.TrainerSpots); CmsAdministrators = DisplayStringHelper.FormatNumberWithLimit( cmsAdministrators, centreDetails.CmsAdministratorSpots ); CmsAdministratorsColour = DisplayColourHelper.GetDisplayColourForPercentage( cmsAdministrators, centreDetails.CmsAdministratorSpots ); CmsManagers = DisplayStringHelper.FormatNumberWithLimit( cmsManagers, centreDetails.CmsManagerSpots ); CmsManagersColour = DisplayColourHelper.GetDisplayColourForPercentage( cmsManagers, centreDetails.CmsManagerSpots ); ContentCreators = DisplayStringHelper.FormatNumberWithLimit( contentCreators, centreDetails.CcLicenceSpots ); ContentCreatorsColour = DisplayColourHelper.GetDisplayColourForPercentage( contentCreators, centreDetails.CcLicenceSpots ); CustomCourses = DisplayStringHelper.FormatNumberWithLimit( numberOfCourses, centreDetails.CustomCourses ); CustomCoursesColour = DisplayColourHelper.GetDisplayColourForPercentage(numberOfCourses, centreDetails.CustomCourses); ServerSpace = DisplayStringHelper.FormatBytesWithLimit( centreDetails.ServerSpaceUsed, centreDetails.ServerSpaceBytes ); ServerSpaceColour = DisplayColourHelper.GetDisplayColourForPercentage( centreDetails.ServerSpaceUsed, centreDetails.ServerSpaceBytes ); }
public void GetNameWithEmailForDisplay_returns_name_only_when_email_is_null_or_whitespace(string?email) { // Given const string fullName = "FirstName LastName"; // When var result = DisplayStringHelper.GetNameWithEmailForDisplay(fullName, email); // Then result.Should().Be(fullName); }
public void FormatBytesWithLimit_returns_expected_string_when_less_than_next_size() { // Given var bytes = Gibibyte - 10; // When var result = DisplayStringHelper.FormatBytesWithLimit(12, bytes); // Then result.Should().Be("12B / 1024MB"); }
public LearningPathwayDefaultsViewModel(CourseDetails courseDetails) { CustomisationId = courseDetails.CustomisationId; CompleteWithinMonths = DisplayStringHelper.ConvertNumberToMonthsString(courseDetails.CompleteWithinMonths); CompletionValidFor = DisplayStringHelper.ConvertNumberToMonthsString(courseDetails.ValidityMonths); Mandatory = courseDetails.Mandatory; AutoRefresh = courseDetails.AutoRefresh; RefreshToCustomisationId = courseDetails.RefreshToCustomisationId; RefreshToCourseName = courseDetails.RefreshToCourseName; AutoRefreshMonths = SetMonthDisplayString(courseDetails.AutoRefreshMonths) + " before expiry"; ApplyLpDefaultsToSelfEnrol = courseDetails.ApplyLpDefaultsToSelfEnrol; }
public CurrentLearningResourceViewModel(ActionPlanResource resource, ReturnPageQuery returnPageQuery) : base( resource, returnPageQuery ) { LaunchResourceLink = resource.ResourceLink; ResourceDescription = resource.ResourceDescription; CatalogueName = resource.CatalogueName; ResourceType = DisplayStringHelper.AddSpacesToPascalCaseString(resource.ResourceType); AbsentInLearningHub = resource.AbsentInLearningHub; ResourceReferenceId = resource.ResourceReferenceId; }
public void GetNameWithEmailForDisplay_returns_correctly_formatted_name_with_email_when_both_are_provided() { // Given const string fullName = "FirstName LastName"; const string email = "*****@*****.**"; // When var result = DisplayStringHelper.GetNameWithEmailForDisplay(fullName, email); // Then result.Should().Be("FirstName LastName ([email protected])"); }
public void GetPotentiallyInactiveAdminName_returns_correctly_formatted_name_for_inactive_admin() { // Given const string firstName = "FirstName"; const string lastName = "LastName"; const bool active = false; // When var result = DisplayStringHelper.GetPotentiallyInactiveAdminName(firstName, lastName, active); // Then result.Should().Be("FirstName LastName (inactive)"); }
public GroupCourseViewModel(GroupCourse groupCourse) { GroupCustomisationId = groupCourse.GroupCustomisationId; Name = groupCourse.CourseName; Supervisor = groupCourse.SupervisorLastName != null ? $"{groupCourse.SupervisorFirstName} {groupCourse.SupervisorLastName}" : null; IsMandatory = groupCourse.IsMandatory ? "Mandatory" : "Not mandatory"; IsAssessed = groupCourse.IsAssessed ? "Assessed" : "Not assessed"; AddedToGroup = groupCourse.AddedToGroup.ToString(DateHelper.StandardDateFormat); CompleteWithin = DisplayStringHelper.ConvertNumberToMonthsString(groupCourse.CompleteWithinMonths); ValidFor = DisplayStringHelper.ConvertNumberToMonthsString(groupCourse.ValidityMonths); }
public BrandCourseViewModel(ApplicationWithSections application) { ApplicationId = application.ApplicationId; ApplicationName = application.ApplicationName; PopularityRating = application.PopularityRating; DisplayTime = DisplayStringHelper.GetTimeStringFromMinutes(application.TotalMins); TimeForScreenReader = DisplayStringHelper.GetTimeStringForScreenReaderFromMinutes(application.TotalMins); Time = application.TotalMins; CategoryName = application.CategoryName; CourseTopic = application.CourseTopic; CreatedDate = application.CreatedDate; Sections = application.Sections.Select(s => new BrandCourseSectionViewModel(s)); }
public GroupDelegateViewModel(GroupDelegate groupDelegate, ReturnPageQuery returnPageQuery) { GroupDelegateId = groupDelegate.GroupDelegateId; GroupId = groupDelegate.GroupId; DelegateId = groupDelegate.DelegateId; TitleName = groupDelegate.SearchableName; Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(groupDelegate.FirstName, groupDelegate.LastName); EmailAddress = groupDelegate.EmailAddress; CandidateNumber = groupDelegate.CandidateNumber; ProfessionalRegistrationNumber = PrnStringHelper.GetPrnDisplayString( groupDelegate.HasBeenPromptedForPrn, groupDelegate.ProfessionalRegistrationNumber ); ReturnPageQuery = returnPageQuery; }
public EmailDelegatesItemViewModel( DelegateUser delegateUser, bool isDelegateSelected ) { Id = delegateUser.Id; Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName); Email = delegateUser.EmailAddress; if (delegateUser.DateRegistered.HasValue) { RegistrationDate = delegateUser.DateRegistered.Value.ToString(DateHelper.StandardDateFormat); } IsDelegateSelected = isDelegateSelected; RegistrationPromptFilters = new Dictionary <int, string>(); }
public GroupCourseViewModel(GroupCourse groupCourse, ReturnPageQuery returnPageQuery) { GroupCustomisationId = groupCourse.GroupCustomisationId; Name = groupCourse.CourseName; Supervisor = DisplayStringHelper.GetPotentiallyInactiveAdminName( groupCourse.SupervisorFirstName, groupCourse.SupervisorLastName, groupCourse.SupervisorAdminActive ); IsMandatory = groupCourse.IsMandatory ? "Mandatory" : "Not mandatory"; IsAssessed = groupCourse.IsAssessed ? "Assessed" : "Not assessed"; AddedToGroup = groupCourse.AddedToGroup.ToString(DateHelper.StandardDateFormat); CompleteWithin = DisplayStringHelper.ConvertNumberToMonthsString(groupCourse.CompleteWithinMonths); ValidFor = DisplayStringHelper.ConvertNumberToMonthsString(groupCourse.ValidityMonths); ReturnPageQuery = returnPageQuery; }
public RemoveGroupDelegateViewModel( GroupDelegate delegateUser, string groupName, int groupId, int?progressId, ReturnPageQuery returnPageQuery ) { GroupId = groupId; GroupName = groupName; DelegateName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( delegateUser.FirstName, delegateUser.LastName ); RemoveStartedEnrolmentsEnabled = progressId.HasValue; ReturnPageQuery = returnPageQuery; }
private CompetencyResourceSignpostingViewModel GetSignpostingResourceParameters(int frameworkId, int frameworkCompetencyId) { var frameworkCompetency = frameworkService.GetFrameworkCompetencyById(frameworkCompetencyId); var parameters = frameworkService.GetSignpostingResourceParametersByFrameworkAndCompetencyId(frameworkId, frameworkCompetency.CompetencyID); var model = new CompetencyResourceSignpostingViewModel(frameworkId, frameworkCompetencyId, frameworkCompetencyId) { NameOfCompetency = frameworkCompetency.Name, }; var learningHubApiReferences = GetBulkResourcesByReferenceIds(model, parameters); var learningHubApiResourcesByRefId = learningHubApiReferences?.ResourceReferences?.ToDictionary(k => k.RefId, v => v); model.CompetencyResourceLinks = ( from p in parameters let resource = !model.LearningHubApiError && learningHubApiResourcesByRefId.Keys.Contains(p.ResourceRefId) ? learningHubApiResourcesByRefId[p.ResourceRefId] : null select new SignpostingCardViewModel() { AssessmentQuestionId = p.AssessmentQuestionId, CompetencyLearningResourceId = p.CompetencyLearningResourceId, Name = resource?.Title ?? p.OriginalResourceName, AssessmentQuestion = p.Question, AssessmentQuestionLevelDescriptors = p.AssessmentQuestionId.HasValue && p.AssessmentQuestionInputTypeId != 2 ? frameworkService.GetLevelDescriptorsForAssessmentQuestionId( p.AssessmentQuestionId.Value, GetAdminId(), p.AssessmentQuestionMinValue, p.AssessmentQuestionMaxValue, p.AssessmentQuestionMinValue == 0).ToList() : null, LevelDescriptorsAreZeroBased = p.AssessmentQuestionMinValue == 0, AssessmentQuestionInputTypeId = p.AssessmentQuestionInputTypeId, MinimumResultMatch = p.MinResultMatch, MaximumResultMatch = p.MaxResultMatch, CompareResultTo = p.CompareResultTo, Essential = p.Essential, ParameterHasNotBeenSet = p.IsNew, Description = resource?.Description, Catalogue = resource?.Catalogue?.Name, ResourceType = DisplayStringHelper.AddSpacesToPascalCaseString(resource?.ResourceType ?? p.OriginalResourceType), ResourceRefId = resource?.RefId ?? p.ResourceRefId, Rating = resource?.Rating ?? p.OriginalRating, UnmatchedResource = learningHubApiReferences?.UnmatchedResourceReferenceIds?.Contains(p.ResourceRefId) ?? false }).ToList(); return(model); }
public RemoveFromCourseViewModel( DetailedCourseProgress progress, bool confirm, DelegateAccessRoute accessedVia, ReturnPageQuery?returnPageQuery ) { DelegateId = progress.DelegateId; Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( progress.DelegateFirstName, progress.DelegateLastName ); CustomisationId = progress.CustomisationId; ProgressId = progress.ProgressId; CourseName = progress.CourseName; Confirm = confirm; AccessedVia = accessedVia; ReturnPageQuery = returnPageQuery; }
public void ReplaceNonAlphaNumericSpaceChars_returns_cleaned_string_with_replacement() { // Given var input = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "1234567890" + "`¬¦!\"£$%^&*)(_+-=[]{};'#:@~\\|,./<>? "; var expectedOutput = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "1234567890" + "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr "; // When var result = DisplayStringHelper.ReplaceNonAlphaNumericSpaceChars(input, "r"); // Then result.Should().Be(expectedOutput); }
public SearchableDelegateGroupViewModel(Group group, ReturnPageQuery returnPageQuery) { Id = group.GroupId; Name = group.GroupLabel; Description = group.GroupDescription; DelegateCount = group.DelegateCount; CourseCount = group.CoursesCount; LinkedToField = group.LinkedToField; LinkedField = group.LinkedToFieldName; AddedByAdminId = group.AddedByAdminId; AddedBy = DisplayStringHelper.GetPotentiallyInactiveAdminName( group.AddedByFirstName, group.AddedByLastName, group.AddedByAdminActive ); ShouldAddNewRegistrantsToGroup = group.ShouldAddNewRegistrantsToGroup ? Yes : No; ChangesToRegistrationDetailsShouldChangeGroupMembership = group.ChangesToRegistrationDetailsShouldChangeGroupMembership ? Yes : No; ReturnPageQuery = returnPageQuery; }
public SearchableRecommendedResourceViewModel( RecommendedResource recommendedResource, int selfAssessmentId, ReturnPageQuery returnPageQuery ) { SelfAssessmentId = selfAssessmentId; LearningResourceReferenceId = recommendedResource.LearningResourceReferenceId; LearningHubReferenceId = recommendedResource.LearningHubReferenceId; ResourceName = recommendedResource.ResourceName; ResourceDescription = recommendedResource.ResourceDescription; ResourceType = DisplayStringHelper.AddSpacesToPascalCaseString(recommendedResource.ResourceType); CatalogueName = recommendedResource.CatalogueName; ResourceLink = recommendedResource.ResourceLink; IsInActionPlan = recommendedResource.IsInActionPlan; IsCompleted = recommendedResource.IsCompleted; LearningLogItemId = recommendedResource.LearningLogId; RecommendationScore = recommendedResource.RecommendationScore; ReturnPageQuery = returnPageQuery; }
public EditDelegateCourseAdminFieldViewModel( EditDelegateCourseAdminFieldFormData formData, DelegateCourseInfo delegateCourseInfo, int progressId, int promptNumber, DelegateAccessRoute accessedVia ) : base(formData) { var courseAdminField = delegateCourseInfo.CourseAdminFields.Single(c => c.PromptNumber == promptNumber); Options = courseAdminField !.Options; Radios = GetRadioItems(delegateCourseInfo, promptNumber); PromptText = courseAdminField.PromptText; CourseName = delegateCourseInfo.CourseName; DelegateName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( delegateCourseInfo.DelegateFirstName, delegateCourseInfo.DelegateLastName ); ProgressId = progressId; AccessedVia = accessedVia; }
public EmailDelegatesItemViewModel( DelegateUser delegateUser, bool isDelegateSelected, IEnumerable <DelegateRegistrationPrompt> delegateRegistrationPrompts, IEnumerable <CentreRegistrationPrompt> centreRegistrationPrompts ) { Id = delegateUser.Id; Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName); Email = delegateUser.EmailAddress; if (delegateUser.DateRegistered.HasValue) { RegistrationDate = delegateUser.DateRegistered.Value.ToString(DateHelper.StandardDateFormat); } IsDelegateSelected = isDelegateSelected; JobGroupId = delegateUser.JobGroupId; var promptsWithOptions = centreRegistrationPrompts.Where(prompt => prompt.Options.Count > 0); RegistrationPromptFilters = DelegatesViewModelFilters.GetRegistrationPromptFilters(delegateRegistrationPrompts, promptsWithOptions); }
public EditDelegateCourseAdminFieldViewModel( int progressId, int promptNumber, DelegateCourseInfo delegateCourseInfo, DelegateAccessRoute accessedVia, ReturnPageQuery?returnPageQuery = null ) : base(delegateCourseInfo, returnPageQuery) { var courseAdminField = delegateCourseInfo.CourseAdminFields.Single(c => c.PromptNumber == promptNumber); Options = courseAdminField.Options; Answer = delegateCourseInfo.GetAnswer(promptNumber); Radios = GetRadioItems(delegateCourseInfo, promptNumber); PromptText = courseAdminField.PromptText; CourseName = delegateCourseInfo.CourseName; DelegateName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( delegateCourseInfo.DelegateFirstName, delegateCourseInfo.DelegateLastName ); ProgressId = progressId; AccessedVia = accessedVia; }
public IActionResult Index( int delegateId, bool isFromViewDelegatePage, ReturnPageQuery?returnPageQuery = null ) { var delegateUser = userDataService.GetDelegateUserById(delegateId) !; if (string.IsNullOrWhiteSpace(delegateUser.EmailAddress)) { return(View("NoEmail")); } var model = new SetDelegatePasswordViewModel( DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName), delegateId, isFromViewDelegatePage, returnPageQuery ); return(View(model)); }
public CentreDashboardViewModel( CentreDashboardInformation dashboardInformation, string userIpAddress, int unacknowledgedNotificationsCount ) { CentreDetails = new DashboardCentreDetailsViewModel( dashboardInformation.Centre, userIpAddress, dashboardInformation.CentreRank ); FirstName = string.IsNullOrWhiteSpace(dashboardInformation.FirstName) ? "User" : dashboardInformation.FirstName; CourseCategory = dashboardInformation.CategoryName ?? "all"; NumberOfDelegates = dashboardInformation.DelegateCount; NumberOfCourses = dashboardInformation.CourseCount; NumberOfAdmins = dashboardInformation.AdminCount; NumberOfSupportTickets = dashboardInformation.SupportTicketCount; ViewNotificationsButtonText = "View " + unacknowledgedNotificationsCount + " notification" + DisplayStringHelper.GetPluralitySuffix(unacknowledgedNotificationsCount); }
public PreviewCertificateViewModel(CertificateInformation certificateInformation) { CentreContactName = certificateInformation.ContactSurname != null ? DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( certificateInformation.ContactForename, certificateInformation.ContactSurname ) : null; DelegateName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly( certificateInformation.DelegateFirstName, certificateInformation.DelegateLastName ); CourseName = certificateInformation.CourseName; SignatureImage = certificateInformation.SignatureImage; CentreLogo = certificateInformation.CentreLogo; CompletionDate = certificateInformation.CompletionDate; CentreName = certificateInformation.CentreName; CertificateModifier = certificateInformation.CertificateModifier; }
public NumberOfAdministratorsViewModel(CentreContractAdminUsage numberOfAdministrators) { Admins = numberOfAdministrators.AdminCount.ToString(); Supervisors = numberOfAdministrators.SupervisorCount.ToString(); Trainers = DisplayStringHelper.FormatNumberWithLimit( numberOfAdministrators.TrainerCount, numberOfAdministrators.TrainerSpots ); CmsAdministrators = DisplayStringHelper.FormatNumberWithLimit( numberOfAdministrators.CmsAdministratorCount, numberOfAdministrators.CmsAdministratorSpots ); CmsManagers = DisplayStringHelper.FormatNumberWithLimit( numberOfAdministrators.CmsManagerCount, numberOfAdministrators.CmsManagerSpots ); CcLicences = DisplayStringHelper.FormatNumberWithLimit( numberOfAdministrators.CcLicenceCount, numberOfAdministrators.CcLicenceSpots ); }