public ActionResult <TweetDto> ReplyToTweet(int id, [FromBody] CreateTweetDto createTweetDto)
        {
            var credentials         = _mapper.Map <Credentials>(createTweetDto.Credentials);
            var user                = _userService.GetAndValidateUser(credentials);
            var tweetBeingRepliedTo = _tweetService.GetTweet(id);
            var tweetReply          = _tweetService.CreateReplyTweet(user, createTweetDto.Content, tweetBeingRepliedTo.Id);

            return(_mapper.Map <TweetDto>(tweetReply));
        }
Exemplo n.º 2
0
        public void Seed()
        {
            GenerateUsers(20);
            GenerateTweets(20);

            var user1 = new User
            {
                Credentials = new Credentials()
                {
                    Username = "******",
                    Password = "******",
                },
                Profile = new Profile()
                {
                    FirstName = "string",
                    LastName  = "string",
                    Email     = "string",
                    Phone     = "string",
                },
            };

            var user2 = new User
            {
                Credentials = new Credentials()
                {
                    Username = "******",
                    Password = "******",
                },
                Profile = new Profile()
                {
                    FirstName = "string2",
                    LastName  = "string2",
                    Email     = "string2",
                    Phone     = "string2",
                },
            };

            var user3 = new User
            {
                Credentials = new Credentials()
                {
                    Username = "******",
                    Password = "******",
                },
                Profile = new Profile()
                {
                    FirstName = "string3",
                    LastName  = "string3",
                    Email     = "string3",
                    Phone     = "string3",
                },
            };

            user1 = _userService.CreateUser(user1);
            user2 = _userService.CreateUser(user2);
            user3 = _userService.CreateUser(user3);

            _userService.FollowUser(user1.Credentials.Username, user2);
            _userService.FollowUser(user2.Credentials.Username, user3);

            var t1 = _tweetService.CreateSimpleTweet(user1, "I am cool #nofilter");

            _tweetService.CreateSimpleTweet(user3, "rise up lol #justGamerThings");
            var t2 = _tweetService.CreateReplyTweet(user2, "omg @string u r so cool #stan", t1.Id);
            var t3 = _tweetService.CreateReplyTweet(user1, "chill baby I know it", t2.Id);
            var t4 = _tweetService.CreateReplyTweet(user2, "omg u replied", t3.Id);
            var t5 = _tweetService.CreateReplyTweet(user3, "@string your a idiot, @string2 I would never treat you like that mlady", t3.Id);
            var t6 = _tweetService.CreateReplyTweet(user2, "uh who tf r u? dont @ me again", t5.Id);
        }