private UserCommentPublicModel PrepareCommentPublicModel(Comment comment, IEnumerable <User> users) { //get the customer var user = users.FirstOrDefault(x => x.Id == comment.UserId); if (user == null) { return(null); } var likeStatus = _customerLikeService.GetCustomerLike <Comment>(ApplicationContext.Current.CurrentUser.Id, comment.Id) == null ? 0 : 1; //and create it's response model var cModel = new UserCommentPublicModel() { EntityName = comment.EntityName, EntityId = comment.EntityId, CommentText = comment.CommentText, AdditionalData = comment.AdditionalData, Id = comment.Id, DateCreatedUtc = comment.DateCreated, DateCreated = DateTimeHelper.GetDateInUserTimeZone(comment.DateCreated, DateTimeKind.Utc, user), CanDelete = comment.UserId == ApplicationContext.Current.CurrentUser.Id || ApplicationContext.Current.CurrentUser.IsAdministrator(), IsSpam = false, //TODO: change it when spam system has been implemented LikeCount = _customerLikeService.GetLikeCount <Comment>(comment.Id), UserName = user.GetPropertyValueAs <string>(PropertyNames.DisplayName), UserProfileUrl = Url.Route("CustomerProfileUrl", new RouteValueDictionary() { { "SeName", user.GetPermalink().ToString() } }), UserProfileImageUrl = _pictureService.GetPictureUrl(user.GetPropertyValueAs <int>(PropertyNames.DefaultPictureId), PictureSizeNames.SmallProfileImage), LikeStatus = likeStatus }; return(cModel); }
private UserCommentPublicModel PrepareCommentPublicModel(Comment comment, IEnumerable <User> users) { //get the customer var user = users.FirstOrDefault(x => x.Id == comment.UserId); if (user == null) { return(null); } //process the comment text _timelinePostProcessor.ProcessInlineTags(comment); var likeStatus = _customerLikeService.GetCustomerLike <Comment>(ApplicationContext.Current.CurrentUser.Id, comment.Id) == null ? 0 : 1; //and create it's response model var cModel = new UserCommentPublicModel() { EntityName = comment.EntityName, EntityId = comment.EntityId, CommentText = comment.CommentText, AdditionalData = comment.AdditionalData, Id = comment.Id, DateCreatedUtc = comment.DateCreated, DateCreated = DateTimeHelper.GetDateInUserTimeZone(comment.DateCreated, DateTimeKind.Utc, user), CanDelete = comment.UserId == ApplicationContext.Current.CurrentUser.Id || ApplicationContext.Current.CurrentUser.IsAdministrator(), IsSpam = false, //TODO: change it when spam system has been implemented LikeCount = _customerLikeService.GetLikeCount <Comment>(comment.Id), LikeStatus = likeStatus, User = user.ToModel(_mediaService, _mediaSettings) }; return(cModel); }