/// <summary> /// Creates a ViewModel instance from the common user profile model returned from the data layer. /// </summary> public static UserProfileViewModel FromDataModel(UserProfile data) { if (data == null) return null; return new UserProfileViewModel { UserId = data.UserId, EmailAddress = data.EmailAddress, FirstName = data.FirstName, LastName = data.LastName, ProfileImageUrl = GravatarHasher.GetImageUrlForEmailAddress(data.EmailAddress) }; }
/// <summary> /// A static mapper function for mapping from the data model to this ViewModel object. /// </summary> public static VideoPreviewViewModel FromDataModel(SuggestedVideos.Dtos.VideoPreview preview, UserProfile author, PlayStats stats, UrlHelper urlHelper) { if (preview == null) return null; return new VideoPreviewViewModel { VideoId = preview.VideoId, Name = preview.Name, AddedDate = preview.AddedDate, PreviewImageLocation = preview.PreviewImageLocation, AuthorFirstName = author.FirstName, AuthorLastName = author.LastName, AuthorProfileUrl = urlHelper.Action("Info", "Account", new { userId = author.UserId }), Views = stats.Views }; }