public static void SetIdenticonAsUserImage(User user) { var code = Guid.NewGuid().GetHashCode(); var profileImage = new IdenticonRenderer().Render(code, SIZE); user.ProfileImageBytes = ProfileImageHelper.ConvertForDb(profileImage); }
private PostForUser _GetPostForUser(Post post, User user, Channel sourceChannel) { var postForUser = _dbContext.PostsForUser.SingleOrDefault(x => x.Post.Id == post.Id && x.User.Id == user.Id && x.SourceChannel.Id == sourceChannel.Id); if (postForUser == null) { postForUser = new PostForUser { Post = post, User = user, WasRead = false, SourceChannel = sourceChannel }; _dbContext.PostsForUser.Add(postForUser); } return postForUser; }
private static string _MapUser(User user) { return user.Name; }
private PostViewModel[] _GetActivePostsForUser(User user) { var posts = _dbContext.PostsForUser .Where(x => x.WasRead == false && x.User.Id == user.Id) .Include(x => x.Post.ByUser) .Include(x => x.Post.Comments) .Include("Post.Comments.ByUser") .OrderByDescending(x => x.Post.Date) .ToArray(); var postsViewModels = Mapper.Map<PostViewModel[]>(posts); return postsViewModels; }
private bool _ValidatePassword(User user, string password) { return Cryptographer.HashPassword(password, user.PasswordSalt) == user.Password; }