private void RemoveComment(int commentID) { var commentManager = CommentSystemManager.NewCommentRemover(); commentManager.Result += (status, comment) => { Device.BeginInvokeOnMainThread(() => { if (status == CommentManagerStatus.Success) { DependencyService.Get <IToast>().LongToast("Komentaras sėkmingai ištrintas"); } else { DependencyService.Get <IToast>().LongToast("Komentaras nebuvo ištrintas"); } }); }; commentManager.RemoveComment(new Comment { CommentID = commentID }); GetComments(viewModel.HelpRequestModel.HelpRequest.Id); }
void GetComments(int helpRequestID) { var commentGetter = CommentSystemManager.NewCommentGetter(); commentGetter.Result += (status, comments, users) => { Device.BeginInvokeOnMainThread(async() => { if (status == CommentGetStatus.Success) { this.users = users; Items.Clear(); Items.Add(viewModel); comments.ForEach(comment => { Items.Add(new CommentModel { Name = users[comment.Username].FirstName + " " + users[comment.Username].LastName, Username = comment.Username, Message = comment.Message, CreatedDate = comment.CreatedDate.ToFullDate(false), Comment = comment, ImageLocation = users[comment.Username].ProfilePictureLocation }); }); } else { await DisplayAlert("Klaida", "Nepavyko įkelti komentarų", "OK"); } CommentList.IsRefreshing = false; }); }; commentGetter.Get(helpRequestID); }
private void PostButton_Clicked(object sender, EventArgs e) { if (SendEditor.Text == null) { return; } else if (SendEditor.Text.Length == 0) { return; } var commentManager = CommentSystemManager.NewCommentPoster(); PostButton.IsEnabled = false; commentManager.Result += (status, comment) => { Device.BeginInvokeOnMainThread(() => { if (status == CommentManagerStatus.Success) { DependencyService.Get <IToast>().LongToast("Komentaras sėkmingai išsiųstas"); Items.Add(new CommentModel { Name = LocalUserManager.LocalUser.FirstName + " " + LocalUserManager.LocalUser.LastName, Username = comment.Username, Message = comment.Message, CreatedDate = DateTime.Now.ToFullDate(), Comment = comment, ImageLocation = LocalUserManager.LocalUser.ProfilePictureLocation }); CommentList.ScrollTo(Items.LastOrDefault(), ScrollToPosition.End, false); } else { DependencyService.Get <IToast>().LongToast("Komentaras nebuvo išsiųstas"); } PostButton.IsEnabled = true; }); }; commentManager.PostComment(new Comment { Message = SendEditor.Text, HelpRequestID = viewModel.HelpRequestModel.HelpRequest.Id, Username = LocalUserManager.LocalUser.Username }); SendEditor.Text = ""; }