private async Task PostNewComment(string comment) { if (!string.IsNullOrWhiteSpace(comment)) { //TODO changed this to recieve comment object instead of event var commentObj = new Comment { Content = comment, SenderId = App.StoredUserFacebookId, DateAndTime = DateTime.Now.ToLocalTime(), ImageSource = App.userProfile.ImageSource }; bool success = false; comments.Add(commentObj); UpdateList(false); commentEntryTop.Text = ""; commentEntryBottom.Text = ""; //commentEntryBottom. if (type == MessageApiManager.CommentType.Converzation) { Conversation cons = await _dataManager.MessageApiManager.WriteToConversation(ConversationId, commentObj); if (cons != null) { success = true; comments = cons.Messages; } } else { List<Comment> coms = await _dataManager.MessageApiManager.CreateComment(ConversationId, type, commentObj); if (coms != null) { success = true; comments = coms; } } if (success) { } else { await App.coreView.displayAlertMessage("Comment Not Posted", "An error happened and the comment was not posted, try again.", "Ok"); } } }
public async Task<List<Comment>> CreateComment(string id, CommentType commentType, Comment comment) { var content = new StringContent(JsonConvert.SerializeObject(comment), Encoding.UTF8, "application/json"); try { var response = await httpClient.PostAsync(new Uri(App.serverUri + "message/comment/" + id + "?commentType="+ commentType), content); if (response.IsSuccessStatusCode) { var recievedContent = await response.Content.ReadAsStringAsync(); var list = JsonConvert.DeserializeObject<List<Comment>>(recievedContent); return list; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(@" ERROR {0}", ex.Message); } return null; }
public InspectManageComment (Comment comment) { InitializeComponent (); BindingContext = comment; }
public async Task<Conversation> WriteToConversation(string id, Comment comment) { var content = new StringContent(JsonConvert.SerializeObject(comment), Encoding.UTF8, "application/json"); try { var response = await httpClient.PutAsync(new Uri(App.serverUri + "message/conversation/writeToConversation/" + id), content); if (response.IsSuccessStatusCode) { var recievedContent = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject<Conversation>(recievedContent); } else { await App.coreView.displayAlertMessage("Connection Error", "Trouble Connecting To Server", "OK"); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(@" ERROR {0}", ex.Message); } return null; }