public QuestionsController() { _usersService = new UsersService(Context, GetPageSize()); _questionsService = new QuestionsService(Context, GetPageSize()); }
private ProfileViewModel InitializeProfile(ApplicationUser currentUser, ApplicationUser profileUser) { var questionService = new QuestionsService(_context, _pageSize); var isCurrentUserFollowing = IsFollowing(currentUser, profileUser); return new ProfileViewModel() { ScreenName = profileUser.ScreenName, FollowsYou = IsFollowing(profileUser, currentUser), Following = IsFollowing(currentUser, profileUser), IsOwnProfile = currentUser != null && currentUser.UserName == profileUser.UserName, AvatarUrl = GetAvatarUrl(profileUser), HeaderUrl = GetHeaderUrl(profileUser), Bio = profileUser.Bio, Location = profileUser.Location, Homepage = GetHomepage(profileUser.Homepage), User = profileUser, QuestionsReplied = questionService.GetQuestionsAnsweredByUser(profileUser), QuestionsAsked = questionService.GetQuestionsAskedByUser(profileUser), FollowerCount = GetFollowerCount(profileUser), FollowingCount = GetFollowingCount(profileUser), FollowButton = GetFollowButtonViewModel(profileUser.UserName, isCurrentUserFollowing, currentUser != null), AnswerLikesCount = _context.AnswerLikes.Count(like => like.Active && like.ApplicationUserId == profileUser.Id), Age = currentUser.Birthday.HasValue ? Helpers.TimeHelper.GetAge(currentUser.Birthday.Value) : null }; }