/// <summary> /// Evaluates a member view model and creates an appropriate link to that member's Profile and Account. /// </summary> /// <param name="html">html helper</param> /// <param name="currentMember">member we wish to create a profile/account link for</param> /// <returns>returns either an anchor tag or span tag depending on whether the member is anonymous/exists</returns> public static MvcHtmlString CombinedProfileAccountLink(this HtmlHelper html, CurrentMemberVM currentMember) { MvcHtmlString returnValue = null; if (currentMember.IsActive) { returnValue = MvcHtmlString.Create("<span>My " + html.ActionLink("Profile", MVC.Member.Profile(currentMember.Id.Value, null)).ToString() + " | " + html.ActionLink("Settings", MVC.Member.Account(currentMember.Id.Value, null)).ToString() + "</span>"); } else if (currentMember.Id.HasValue) { returnValue = html.ActionLink("Activate profile", MVC.Member.ChangePassword(null)); } else { returnValue = MvcHtmlString.Create("<span>Anonymous</span>"); } return returnValue; }
/// <summary> /// Evaluates a member view model and creates an appropriate link to that member's profile. /// </summary> /// <param name="html">html helper</param> /// <param name="viewModel">member we wish to create a profile link for</param> /// <param name="currentMember">member we wish to create a profile/account link for</param> /// <returns>returns either an anchor tag or span tag depending on whether the member is anonymous/exists</returns> public static MvcHtmlString ProfileLink(this HtmlHelper html, MemberVM viewModel, CurrentMemberVM currentMember, int cutOff = 0) { MvcHtmlString returnValue = null; string linkText; if (viewModel == null || viewModel.IsAnonymous) { linkText = "Anonymous"; if (cutOff > 0) { linkText = IWStringUtility.TruncateClean(linkText, cutOff); } returnValue = MvcHtmlString.Create("<span>" + linkText + "</span>"); } else if (currentMember != null && viewModel.Id == currentMember.Id) { if (currentMember.IsActive) { linkText = "You"; if (cutOff > 0) { linkText = IWStringUtility.TruncateClean(linkText, cutOff); } returnValue = html.ActionLink(linkText, MVC.Member.Profile(viewModel.Id.Value, null)); } else { linkText = "Activate profile"; if (cutOff > 0) { linkText = IWStringUtility.TruncateClean(linkText, cutOff); } returnValue = html.ActionLink(linkText, MVC.Member.Profile(viewModel.Id.Value, null)); } } else { linkText = viewModel.DisplayName; if (cutOff > 0) { linkText = IWStringUtility.TruncateClean(linkText, cutOff); } returnValue = html.ActionLink(linkText, MVC.Member.Profile(viewModel.Id.Value, null)); } return returnValue; }
public ProfileVM(ProviderMember aMember, ProviderCurrentMember currentMember, int page) { string userName = null; CurrentMember = new CurrentMemberVM(currentMember, aMember); if (CurrentMember.CanEdit) { userName = aMember.DisplayAdministrativeName; } else { userName = aMember.DisplayName; } int skip = page * BLURBS_PER_PAGE; if(skip > MAX_BLURBS) { ArticleList = new List<ArticleVM>(); } else { bool? showPublished = true; if (CurrentMember.CanEdit) { showPublished = null; } bool? showHidden = false; if (CurrentMember.CanEdit) { showHidden = null; } ArticleList = ProviderArticle.LoadNewestBy(aMember, skip, BLURBS_PER_PAGE, showHidden, showPublished) .ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember)); } IsLastPage = ArticleList.Count < BLURBS_PER_PAGE; NextPage = page + 1; if (aMember.HasValidAltId(ProviderAlternateMemberId.AlternateType.Domain)) { ProviderDomain aDomain = aMember.Domains[0]; HasWeb = true; WebUri = aDomain.Domain.AbsoluteUri; WebDisplay = IWStringUtility.TruncateClean(aDomain.DisplayName, ProviderMember.UserNameSize); } PageTitle = userName + " Profile"; HeaderTitle = IWStringUtility.TruncateClean(userName, 28); Birthday = String.Format("{0:MMMM d, yyyy}", aMember.CreateDate); MemberId = aMember.Id; UserName = userName; ProfileImage = MemberBL.GetProfileImage(aMember); HasBio = !string.IsNullOrWhiteSpace(aMember.Bio); Bio = aMember.Bio; }