コード例 #1
0
        public IActionResult SavedTweets(string userId)
        {
            if (userId == null)
            {
                return(this.BadRequest());
            }

            var user = this.userManager.GetById(userId);

            if (user == null)
            {
                return(this.NotFound());
            }

            var tweets = this.tweetRepo.GetAllByUserId(userId);

            var model = new SavedTweetsViewModel
            {
                UserId   = user.Id,
                Username = user.UserName,
                Tweets   = tweets.Select(t => this.mapper.Map <Tweet, TweetViewModel>(t)).ToList()
            };

            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> SavedTweets(string userId)
        {
            var userExists = await this.adminUserSevice.UserExistsAsync(userId);

            if (!userExists)
            {
                return(this.View("NotFound"));
            }

            var savedTweets = this.tweetStatisticsService.GetSavedTweetsByUserId(userId);

            var vm = new SavedTweetsViewModel
            {
                SavedTweetModels = savedTweets,
                UserId           = userId
            };

            return(this.View(vm));
        }