/// <summary> /// This method gets the x most recent upvotes from the filled Upvote account to the author of the given post /// </summary> /// <param name="author">The author of the post</param> /// <param name="vars">Validation variables incl. upvote account name and various other variables to validate the post against</param> /// <returns>Returns the most recent upvotes and the one matching given minimum percentage criteria</returns> private GetAccountVotesViewModel GetLastUpvotesFromUpvoteAccountToAuthor(string author, ValidationVariables vars) { var model = new GetAccountVotesViewModel(); model.MinPercentage = vars.MinPercentageUpvoteFromUpvoteAccount; // get top x most recent posts containing the upvote var posts = _postService.GetMostRecentPostsContainingVoter(author, vars.UpvoteAccount, ConfigurationHelper.RetrieveUpvoteAccountVoteCount); if (posts != null && posts.Any()) { // map results to our FindVotesItemModel foreach (var p in posts) { var pm = DiscussionMapper.ToFindVotesItemModel(p, vars.UpvoteAccount); model.LastVotes.Add(pm); } // get timestamp details of most recent highest upvote // this is not stored in hivemind, so we need to make a call to Steem API if (model.MostRecentUpvote != null) { // get vote details from Steem API's because hivemind doesn't contain detailed vote data var lastUpdate = GetVoteDateOfMostRecentUpvote(author, model.MostRecentUpvote.permlink, vars.UpvoteAccount); if (lastUpdate.HasValue) { model.MostRecentUpvote.last_update = lastUpdate.Value; } } } return(model); }
/// <summary> /// This method calls the get_discussions_by_blog method from Steem API and returns the mapped list of <see cref="DiscussionListViewModel" /> models /// </summary> /// <param name="accountName">The name of the account to get posts for</param> /// <returns>List of <see cref="DiscussionListViewModel" /> models</returns> private List <DiscussionListViewModel> GetAccountPosts(string accountName) { var postCountToGet = 30; var posts = new List <DiscussionListViewModel>(); try { using (var csteemd = new CSteemd(ConfigurationHelper.HostName)) { var steemResponse = csteemd.get_discussions_by_blog(accountName, postCountToGet); var discussionList = new List <GetDiscussionModel>(); if (steemResponse != null && steemResponse.Count > 0) { foreach (var item in steemResponse) { var disc = item.ToObject <GetDiscussionModel>(); var post = DiscussionMapper.ToDiscussionListViewModel(disc, accountName); posts.Add(post); } } } } catch (Exception ex) { _log.Error(ex); } return(posts); }