public static void HydrateUserData(IPrincipal user, IEnumerable <Domain.Models.Comment> comments) { if (user.Identity.IsAuthenticated && (comments != null && comments.Any())) { string userName = user.Identity.Name; if (!String.IsNullOrEmpty(userName)) { using (var repo = new Repository()) { var votes = repo.UserVoteStatus(userName, ContentType.Comment, comments.Select(x => x.ID).ToArray()); var q = new QueryUserBlocks(); var blockedUsers = q.Execute().Where(x => x.Type == DomainType.User); foreach (var comment in comments) { HydrateUserData(user, comment, false, votes, blockedUsers); //comment.IsOwner = comment.UserName == userName; //var voteValue = votes.FirstOrDefault(x => x.ID == comment.ID); //comment.Vote = (voteValue == null ? 0 : voteValue.Value); //comment.IsSaved = UserHelper.IsSaved(ContentType.Comment, comment.ID); //Protect(comment); } } } } }
public static bool IsSenderBlocked(string sender, string recipient) { var q = new QueryUserBlocks(recipient); var blocks = q.Execute(); if (blocks != null) { return(blocks.Any(x => x.Type == DomainType.User && x.Name.Equals(sender, StringComparison.OrdinalIgnoreCase))); } return(false); }
public static bool IsSenderBlocked(string sender, string recipient) { var q = new QueryUserBlocks(recipient); var blocks = q.Execute(); if (blocks != null) { return(blocks.Any(x => x.Type == DomainType.User && x.Name.ToLower() == sender.ToLower())); } return(false); }