public void Create(List <TweetRequest> request) { var entity = Mapper.Map <List <TweetRequest>, List <TweetEntity> >(request); LimparBase(); _tweetRepository.Create(PrepararInsert(entity)); _tweetRepository.SaveChanges(); }
public async Task <GenericResult <tweetModels.Tweet, string> > CreateTweet(CreateTweetRequest createTweetRequest) { if (createTweetRequest is null) { throw new System.ArgumentNullException(nameof(createTweetRequest)); } var result = new GenericResult <tweetModels.Tweet, string>(); if (string.IsNullOrWhiteSpace(createTweetRequest.Content)) { result.Error = "Content cannot be empty"; return(result); } var tweet = CreateTweetFromCreateTweetRequest(createTweetRequest); await _tweetRepository.Create(tweet); var tweetEvent = new TweetEvent { Type = TweetEventType.Created, TweetId = tweet.Id }; _rabbitMqClient.PushToExchange(Constants.TweetsExchangeName, tweetEvent); result.SuccessResult = tweet; return(result); }
public TweetViewModel Create(TweetViewModel model) { var entity = mapper.Map <TweetViewModel, TweetEntity>(model); var createdEntity = repository.Create(entity); var output = mapper.Map <TweetEntity, TweetViewModel>(createdEntity); return(output); }
public async Task <Tweet> Create(Tweet tweet) { if (tweet.UserId == null || tweet.Text.Length < 3) { throw new ArgumentException("Invalid tweet"); } tweet = await _repository.Create(tweet); return(tweet); }
public object Post(CreateTweet request) { var tweet = new Tweet { Id = Guid.NewGuid(), Text = request.Text, User = new User { Nickname = request.UserNickname } }; _tweetRepo.Create(tweet); return(tweet); }
public bool CreateTweet(TweetModel tweet) { bool isCreated = false; try { tweet.createdAt = DateTime.Now; isCreated = _tweetRepository.Create(tweet); } catch (Exception ex) { string msg = ex.Message; isCreated = false; } return(isCreated); }
public void ProcessTweet(ITweet tweet) { var vtweet = new Tweet(); if (_emojiService.ContainsEmojis(tweet.FullText)) { vtweet.ContainsEmojis = true; _emojiService.TrackEmojis(tweet.FullText); } if (_hashTagService.ContainsHashTags(tweet)) { vtweet.ContainsHashTags = true; _hashTagService.TrackHashTags(tweet); } if (_urlsService.ContainsUrls(tweet)) { vtweet.ContainsUrls = true; _urlsService.TrackUrls(tweet); } vtweet.ContainsPhotos = _mediaService.ContainsPhoto(tweet); _tweetRepository.Create(vtweet); }
public void Create(TweetViewModel tweet) { Tweet tweetEntity = mapper.Map <Tweet>(tweet); tweetRepository.Create(tweetEntity); }
public bool postTweet(TweetModel tweetModel) { return(_tweetRepository.Create(tweetModel)); }