public DataGridProfileDataV40 GetDataGridProfileItems(SimpleTypeDataContract <string> guid) { DataGridProfileDataV40 result = new DataGridProfileDataV40() { Header = guid.Header, Body = new List <DataGridProfileItemMsg>() }; List <ProfileItem> profileItems = new ProfileBiz().GetDataGridProfileItems(guid.Value); if (profileItems != null && profileItems.Count > 0) { List <string> userIds = new List <string>(); foreach (var item in profileItems) { userIds.Add(item.InUser); } var userList = new KeystoneAuthService().BatchGetUserInfo(userIds); int i = 0; foreach (var item in profileItems) { result.Body.Add(new DataGridProfileItemMsg { Owner = userList.Body[i], DataGridProfileXml = item.ProfileValue }); i++; } } return(result); }
public bool HasUserProfileImage(int userId) { string value; var keyFound = ProfileBiz.TryReadUserProfileValue(userId, ProfileKeyValueType.IsProfileImageSet, out value); return(keyFound && value == "1"); }
public BusinessIntroducePM ReadUserBusinesIntroduce(int userId) { string text; return(new BusinessIntroducePM() { Text = ProfileBiz.TryReadUserProfileValue(userId, ProfileKeyValueType.UserBusinessIntroduceText, out text) ? text : "" }); }
public SimpleTypeDataContract <List <UserProfile> > Query(ProfileQueryV40 contract) { var queryEntity = contract.Body.ToProfileDataQueryEntity(); var result = new ProfileBiz().GetProfiles(queryEntity); return(new SimpleTypeDataContract <List <UserProfile> > { Header = contract.Header, Value = result.ToUserProfileEntities() }); }
public UserProfileService() { UnitOfWork = new CoreUnitOfWork(); UserBiz = new UserBiz(UnitOfWork); MembershipBiz = new MembershipBiz(UnitOfWork); ProfileBiz = new ProfileBiz(UnitOfWork); ArticleBiz = new ArticleBiz(UnitOfWork); BlogBiz = new BlogBiz(UnitOfWork); EducationalResumeBiz = new EducationalResumeBiz(UnitOfWork); VisitBiz = new VisitBiz(UnitOfWork); JobResumeBiz = new JobResumeBiz(UnitOfWork); FollowBiz = new FollowBiz(UnitOfWork); }
public void UpdateUserSocialNetworkUrls(UserIdentity userIdentity, ProfileSocialNetworkLinksPM profileSocialNetworkLinksPM) { var linkedInUrl = string.IsNullOrWhiteSpace(profileSocialNetworkLinksPM.LinkedInUrl) ? "" : profileSocialNetworkLinksPM.LinkedInUrl.Trim(); var facebookUrl = string.IsNullOrWhiteSpace(profileSocialNetworkLinksPM.FacebookUrl) ? "" : profileSocialNetworkLinksPM.FacebookUrl.Trim(); var twitterUrl = string.IsNullOrWhiteSpace(profileSocialNetworkLinksPM.TwitterUrl) ? "" : profileSocialNetworkLinksPM.TwitterUrl.Trim(); var profileKeyValues = new List <ProfileKeyValue>(); profileKeyValues.Add(new ProfileKeyValue(ProfileKeyValueType.LinkedInUrl, linkedInUrl)); profileKeyValues.Add(new ProfileKeyValue(ProfileKeyValueType.FacebookUrl, facebookUrl)); profileKeyValues.Add(new ProfileKeyValue(ProfileKeyValueType.TwitterUrl, twitterUrl)); ProfileBiz.SetUserProfile(userIdentity.UserId, profileKeyValues); UnitOfWork.SaveChanges(); }
public void CropUserProfileImages(int userId, ProfileImageCropInfoPM cropInfo) { var originalImagePath = AppFileManager.GetUserProfileImagePath(userId, ProfileImageSize.Original); var extension = Path.GetExtension(originalImagePath); var largeImagePath = AppFileManager.CalculateUserProfileImagePath(userId, ProfileImageSize.Large, extension); var mediumImagePath = AppFileManager.CalculateUserProfileImagePath(userId, ProfileImageSize.Medium, extension); var smallImagePath = AppFileManager.CalculateUserProfileImagePath(userId, ProfileImageSize.Small, extension); var sourceImageCropArea = cropInfo.GetSourceImageCropArea(); AppFileManager.RemoveUserProfileImages(userId, ProfileImageSize.Large, ProfileImageSize.Medium, ProfileImageSize.Small); ImageHelper.CropImage(originalImagePath, sourceImageCropArea, new Size(300, 300), largeImagePath); ImageHelper.CropImage(originalImagePath, sourceImageCropArea, new Size(80, 80), mediumImagePath); ImageHelper.CropImage(originalImagePath, sourceImageCropArea, new Size(40, 40), smallImagePath); File.Delete(originalImagePath); ProfileBiz.SetUserProfile(userId, ProfileKeyValueType.IsProfileImageSet, "1"); UnitOfWork.SaveChanges(); }
public ProfileStatisticsAndSocialLinksPM ReadProfileStatisticsAndSocialLinks(int userId) { var userLinks = ProfileBiz.ReadUserProfileValues(userId, ProfileKeyValueType.WebSiteUrl, ProfileKeyValueType.FacebookUrl, ProfileKeyValueType.TwitterUrl, ProfileKeyValueType.LinkedInUrl); var articlesCount = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(); var blogsCount = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(); return(new ProfileStatisticsAndSocialLinksPM() { WebSiteUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.WebSiteUrl)?.Value, FacebookUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.FacebookUrl)?.Value, TwitterUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.TwitterUrl)?.Value, LinkedInUrl = userLinks.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.LinkedInUrl)?.Value, TotalArticles = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(), TotalBlogPosts = ArticleBiz.ReadUserPublishedContents(userId, ContentType.BlogPost).Count(), TotalVisits = VisitBiz.ReadUserTodayTotalVisits(userId), }); }
public UserInfoForHomePageModelContainer ReadUserInfoForProfilePage(int userId, UserIdentity userIdentity) { var user = UserBiz.Read(u => u.Id == userId) .Include(u => u.Membership) .Include(u => u.EducationalResumes.Select(x => x.Organization)) .Include(u => u.EducationalResumes.Select(x => x.UniversityField)) .Include(u => u.JobResumes.Select(x => x.Organization)) .Include(u => u.JobResumes.Select(x => x.Job)) .Single(); var profileKeyValues = ProfileBiz.ReadUserProfileValues(userId, ProfileKeyValueType.WebSiteUrl, ProfileKeyValueType.FacebookUrl, ProfileKeyValueType.TwitterUrl, ProfileKeyValueType.LinkedInUrl, ProfileKeyValueType.AboutMe); var userBlog = BlogBiz.ReadSingleOrDefault(b => b.CreatorId == userId); return(new UserInfoForHomePageModelContainer() { UserId = userId, FirstName = user.FirstName, LastName = user.LastName, AboutMe = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.AboutMe)?.Value, WebSiteUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.WebSiteUrl)?.Value, FacebookUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.FacebookUrl)?.Value, TwitterUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.TwitterUrl)?.Value, LinkedInUrl = profileKeyValues.SingleOrDefault(kv => kv.Type == ProfileKeyValueType.LinkedInUrl)?.Value, TotalArticles = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(), TotalBlogPosts = ArticleBiz.ReadUserPublishedContents(userId, ContentType.BlogPost).Count(), TotalVisits = VisitBiz.ReadUserTodayTotalVisits(userId), LatestArticles = ArticleBiz.ReadUserLatestPublishedArticles(userId, 200).MapTo <ContentInfo2PM>().ToList(), LatestBlogPosts = BlogBiz.ReadUserLatestPosts(userId, 5).MapTo <ContentInfo2PM>().ToList(), EducationalResumes = user.EducationalResumes.OrderByDescending(x => x.EducationGrade).Select(x => x.GetPresentationModel()).ToList(), JobResumes = user.JobResumes.OrderByDescending(x => x.StartYear).Select(x => x.GetPresentationModel()).ToList(), WeblogName = userBlog?.Name, RegistrationDateString = user.Membership.CreateDate.ToPersianDate(), CurrentUserFollowsThisUser = userIdentity != null?FollowBiz.AnyFollow(userIdentity.UserId, userId) : false, Followers = FollowBiz.ReadFollowersCount(userId) }); }
public void UpdateUserGeneralSettings(UserIdentity userIdentity, ProfileGeneralSettingsPM generalSettings) { // Update User var user = UserBiz.Find(userIdentity.UserId); user.FirstName = generalSettings.FirstName; user.LastName = generalSettings.LastName; // Update Profile var profileKeyValues = new List <ProfileKeyValue>(); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.MobileNumber, Value = string.IsNullOrWhiteSpace(generalSettings.MobileNumber) ? "" : generalSettings.MobileNumber.Trim() }); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.WebSiteUrl, Value = string.IsNullOrWhiteSpace(generalSettings.WebSiteUrl) ? "" : generalSettings.WebSiteUrl.Trim() }); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.AboutMe, Value = string.IsNullOrWhiteSpace(generalSettings.AboutMe) ? "" : generalSettings.AboutMe.Trim() }); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.Sexuality, Value = generalSettings.Sexuality.HasValue ? ((int)generalSettings.Sexuality).ToString() : null }); ProfileBiz.SetUserProfile(userIdentity.UserId, profileKeyValues); UnitOfWork.SaveChanges(); userIdentity.FirstName = user.FirstName; userIdentity.LastName = user.LastName; }
public DefaultDataContract Save(SimpleTypeDataContract <List <UserProfile> > contract) { var biz = new ProfileBiz(); foreach (var userProfile in contract.Value) { var entity = biz.GetProfile(new ProfileQueryEntity { ApplicationId = userProfile.ApplicationId, InUser = userProfile.InUser, ProfileType = userProfile.Key }); if (entity == null) { entity = new ProfileEntity { ApplicationId = userProfile.ApplicationId, InUser = userProfile.InUser, ProfileType = userProfile.Key, ProfileValue = userProfile.Data }; biz.Create(entity); } else { entity.ProfileValue = userProfile.Data; entity.InDate = DateTime.Now; biz.Update(entity); } } return(new DefaultDataContract { Header = contract.Header }); }
public void UpdateBusinesIntroduce(UserIdentity userIdentity, BusinessIntroducePM businessIntroduce) { ProfileBiz.SetUserProfile(userIdentity.UserId, ProfileKeyValueType.UserBusinessIntroduceText, businessIntroduce.Text); UnitOfWork.SaveChanges(); }