/// <summary> /// This method gets the post details response from Steem API /// </summary> /// <param name="accountName">The name of the account</param> /// <param name="permlink">The permlink of the post</param> /// <returns>Returns the result mapped to <see cref="GetDiscussionModel" /></returns> private GetDiscussionModel GetDiscussion(string accountName, string permlink) { var blogPost = new GetDiscussionModel(); try { using (var csteemd = new CSteemd(ConfigurationHelper.HostName)) { var response = csteemd.get_discussion(accountName, permlink); if (response != null) { blogPost = response.ToObject <GetDiscussionModel>(); } } } catch (Exception ex) { _log.Error(ex); } return(blogPost); }
public static DiscussionListViewModel ToDiscussionListViewModel(GetDiscussionModel input, string accountName) { var output = new DiscussionListViewModel(); output.Author = input.author; // it is a Resteem if the author of the post is not the account itself output.IsResteem = output.Author != accountName; // Deserialize json_metadata to get main image var jsonMetaData = JsonConvert.DeserializeObject <DiscussionJsonMetadata>(input.json_metadata); // set first image as main image if (jsonMetaData.image != null && jsonMetaData.image.Any()) { output.MainImage = jsonMetaData.image.FirstOrDefault(); } if (!output.IsResteem) { output.PendingPayout = CalculationHelper.ParsePayout(input.pending_payout_value); // if pending payout = 0, it might be the case that it is already paid out, so get the paid out value if (output.PendingPayout == 0) { output.PaidOut = CalculationHelper.ParsePayout(input.total_payout_value); output.PaidOutTotal = output.PaidOut + CalculationHelper.ParsePayout(input.curator_payout_value); } } output.Permlink = input.permlink; output.ParentPermlink = input.parent_permlink; output.Title = input.title; output.CreatedAt = input.created; output.PostPayoutDate = output.CreatedAt.AddDays(7); return(output); }