private async void PostReplyCommandExecute() { if (this.IsPostingRepy) { return; } this.IsPostingRepy = true; try { ReplyPostData post = new ReplyPostData() { Content = this.NewReplyText, Post = this.idGuid }; ReplyEntity repy = await App.Client.ReplyAsync(post); this.Replys.Clear(); this.NewReplyText = string.Empty; } catch (ApiException exception) { this.Message = exception.ToString(); } finally { this.IsPostingRepy = false; } this.LoadItemById(this.idGuid); }
/// <summary> /// 回复贴吧 /// </summary> /// <returns></returns> public int Reply(ReplyPostData replyPostData) { string tbs = GetTbs(); string url = "http://tieba.baidu.com/f/commit/post/add"; Dictionary <string, string> postData = new Dictionary <string, string>(); postData.Add("ie", "utf-8"); postData.Add("kw", replyPostData.Kw); postData.Add("fid", replyPostData.Fid.ToString()); postData.Add("tid", replyPostData.Tid.ToString()); postData.Add("vcode_md5", m_vcodeMd5); postData.Add("tbs", tbs); postData.Add("content", replyPostData.Content); postData.Add("files", "[]"); postData.Add("__type__", "reply"); if (!string.IsNullOrEmpty(m_vcode)) { postData.Add("vcode", m_vcode); } string formData = ""; foreach (var item in postData.Keys) { formData += item + "=" + postData[item] + "&"; } formData = formData.TrimEnd('&'); string content = Request.PostRequest(url, formData); return(JieXi(content)); }
private async Task UpdatePostReplyCount(ReplyPostData daten, SqlConnection connection) { const string IdParameterName = "@ID"; var commandString = @$ "UPDATE POST SET REPLYCOUNT = ( SELECT COUNT(*) FROM REPLY WHERE REPLY.POST = {IdParameterName}
public async Task <ReplyPostResultData> Post([FromBody] ReplyPostData daten) { using var connection = this.userService.Connection; var newReply = await this.SavePostEntity(daten, connection); await this.UpdatePostReplyCount(daten, connection); connection.Close(); var result = new ReplyPostResultData(); result.CopyPropertiesFrom(newReply); return(result); }
private async Task <ReplyEntity> SavePostEntity(ReplyPostData daten, SqlConnection connection) { var user = await this.userDatabaseAccess.Get(this.userService.Username, connection); var newReply = new ReplyEntity(); newReply.CopyPropertiesFrom(daten); newReply.Creationdate = DateTime.Now; newReply.Author = user.Id; using var context = new DatabaseContext(connection); await context.Reply.AddAsync(newReply); await context.SaveChangesAsync(); return(newReply); }