Exemplo n.º 1
0
        public async Task <ServiceStatus> UpdateTweet(int id,
                                                      TweetRequest updatedTweetRequest, string userId)
        {
            var tweet = await _tweetsRepository.GetTweet(id);

            if (tweet == null)
            {
                return(ServiceStatus.NotFound);
            }

            if (!tweet.UserID.Equals(userId))
            {
                return(ServiceStatus.UnauthorizedAction);
            }

            tweet.TweetContent   = updatedTweetRequest.Content;
            tweet.LastTimeOfEdit = DateTime.UtcNow;
            await _tweetsRepository.UpdateTweet(tweet.ID, tweet);

            return(ServiceStatus.Success);
        }