public ActionResult UserContact(UserModel user) { var model = new Dictionary<string, string> { { "Profile", Url.RouteUrl("UserProfile", new {username = user.UserName}) } }; if (user.FacebookProfile != null) model.Add("Facebook", string.Format("http://www.facebook.com/profile.php?id={0}", user.FacebookProfile)); if (user.TwitterProfile != null) model.Add("Twitter", string.Format("http://twitter.com/account/redirect_by_id?id={0}", user.TwitterProfile)); if (!string.IsNullOrEmpty(user.Email) && user.EmailDisclosureLevel == DisclosureLevel.Public) model.Add("Email", string.Format("mailto:{0}", user.Email.EncodeEmail())); if (!string.IsNullOrEmpty(user.Telephone) && user.TelephoneDisclosureLevel == DisclosureLevel.Public) model.Add("Call", string.Format("tel:{0}", user.Telephone)); if (!string.IsNullOrEmpty(user.Website) && user.WebsiteDisclosureLevel == DisclosureLevel.Public) model.Add("Website", user.Website); return PartialView("_UserContact", model); }
public ActionResult OrganiserContact(ProjectModel project, UserModel organiser, bool isOwner = false) { bool isVolunteer = _workContext.CurrentUser != null && project.Volunteers.Any(x => x.Id == _workContext.CurrentUser.Id); var model = new Dictionary<string, string>(); if (organiser.FacebookProfile != null) model.Add("Facebook", string.Format("http://www.facebook.com/profile.php?id={0}", organiser.FacebookProfile)); if (organiser.TwitterProfile != null) model.Add("Twitter", string.Format("http://twitter.com/account/redirect_by_id?id={0}", organiser.TwitterProfile)); if (isOwner) { if (!string.IsNullOrEmpty(project.EmailAddress) && project.EmailDisclosureLevel == DisclosureLevel.Public || (project.EmailDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Email", string.Format("mailto:{0}", project.EmailAddress.EncodeEmail())); if (!string.IsNullOrEmpty(project.Telephone) && project.TelephoneDisclosureLevel == DisclosureLevel.Public || (project.TelephoneDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Call", string.Format("tel:{0}", project.Telephone)); if (!string.IsNullOrEmpty(project.Website) && project.WebsiteDisclosureLevel == DisclosureLevel.Public || (project.WebsiteDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Website", project.Website); } else { if (!string.IsNullOrEmpty(project.EmailAddress) && organiser.EmailDisclosureLevel == DisclosureLevel.Public || (organiser.EmailDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Email", string.Format("mailto:{0}", organiser.Email.EncodeEmail())); if (!string.IsNullOrEmpty(project.Telephone) && organiser.TelephoneDisclosureLevel == DisclosureLevel.Public || (organiser.TelephoneDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Call", string.Format("tel:{0}", organiser.Telephone)); if (!string.IsNullOrEmpty(project.Website) && organiser.WebsiteDisclosureLevel == DisclosureLevel.Public || (organiser.WebsiteDisclosureLevel == DisclosureLevel.VolunteersOnly && isVolunteer)) model.Add("Website", organiser.Website); } return PartialView("_OrganiserContact", model); }
public static UserModel ToModel(this User entity) { if (entity == null) return null; var model = new UserModel { Active = entity.Active, ContactUsBio = entity.ContactUsBio, CreatedDate = entity.CreatedDate, DisplayName = entity.DisplayName, Email = entity.Email, EmailDisclosureId = entity.EmailDisclosureId, EmailDisclosureLevel = entity.EmailDisclosureLevel, FacebookDisplayName = entity.FacebookDisplayName, FacebookProfile = entity.FacebookProfile, Id = entity.Id, LastLoginDate = entity.LastLoginDate, PrimaryAuthMethod = entity.PrimaryAuthMethod, PrimaryAuthMethodId = entity.PrimaryAuthMethodId, ProfilePicture = entity.ProfilePicture, ShowOnContactUs = entity.ShowOnContactUs, Telephone = entity.Telephone, TelephoneDisclosureId = entity.TelephoneDisclosureId, TelephoneDisclosureLevel = entity.TelephoneDisclosureLevel, TwitterDisplayName = entity.TwitterDisplayName, TwitterProfile = entity.TwitterProfile, UserName = entity.UserName, UserRoles = entity.UserRoles.Select(ToModel).ToList(), Website = entity.Website, WebsiteDisclosureId = entity.WebsiteDisclosureId, WebsiteDisclosureLevel = entity.WebsiteDisclosureLevel }; return model; }