private void AddButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(EnterComment.Text)) { EnterComment.PlaceholderText = "Empty comment!"; EnterComment.PlaceholderForeground = new SolidColorBrush(Colors.Red); } else { EnterComment.PlaceholderForeground = new SolidColorBrush(Colors.Gray); EnterComment.PlaceholderText = "Write your comment here!"; var tag = (sender as Button).Tag; long taskId = (long)tag; Comment comment = new Comment(); comment.CommentToTaskId = taskId; comment.AuthorName = App.CurrentUser; comment.Content = EnterComment.Text; comment.CommentId = DateTime.Now.Ticks; comment.Date = DateTime.Now; CommentDB.AddComment(comment); comments.Add(comment); //comments = CommentDB.GetComments(taskId); CommentsList.ItemsSource = comments; EnterComment.Text = ""; } }
public ActionResult Comment(int user_id, int weike_id, string content, int parent) { Comment comment = new Comment(0, user_id, weike_id, DateTime.Now, content); CommentDB.Insert(comment); return(Json(true)); }
private void TasksList_SelectionChanged(object sender, SelectionChangedEventArgs e) { TaskModel task = TasksList.SelectedItem as TaskModel; if (task != null) { TitleTxt.Text = task.TaskName; bool IsAlreadyFav = UserDB.IsFavouriteTask(task.TaskId, App.CurrentUser); if (!IsAlreadyFav) { UserDB.AddFavouriteTaskIds(task.TaskId, App.CurrentUser); } fav = UserDB.GetFavorite(task.TaskId, App.CurrentUser); StarBtnDetails.DataContext = fav; comments = CommentDB.GetComments(task.TaskId); CommentsList.ItemsSource = comments; AddButton.Tag = task.TaskId; DetailsFrame.Navigate(typeof(DetailView), task, new SuppressNavigationTransitionInfo()); } double Acutalwidth = this.ActualWidth; if (ActualWidth < 700) { TasksList.Visibility = Visibility.Collapsed; ComboboxPanel.Visibility = Visibility.Collapsed; DetailAndDiscussion.Visibility = Visibility.Visible; BackBtn.Visibility = Visibility.Visible; } if (ActualWidth >= 700) { TasksList.Visibility = Visibility.Visible; DetailAndDiscussion.Visibility = Visibility.Visible; } }
public void OnLoaded(Comment comment) { UserModel commentUser = UserDB.GetUser(comment.AuthorName); this.AvatarPic.DataContext = commentUser; _myReaction = CommentDB.GetReactionObject(comment.CommentId, App.CurrentUser); this.CurrentReactionBtn.DataContext = _myReaction; }
/// <summary> /// Adds a comment to the photo. /// </summary> /// <param name="comment">The comment to add.</param> public void AddComment(Comment comment) { CommentDB db = new CommentDB(token.DBConnection); db.Insert(this, comment); // Add the comment to the current comment cache comments.Add(comment); }
public void DeleteCommentSuccess() { int id = CommentDB.GetCommentsByPostId(active, 1)[0].Id; int oldNumberOfCommentsByPostId = CommentDB.GetCommentsByPostId(active, 1).Count; CommentDB.DeleteComment(id); int newNumberOfCommentsByPostId = CommentDB.GetCommentsByPostId(active, 1).Count; Assert.AreEqual(oldNumberOfCommentsByPostId - 1, newNumberOfCommentsByPostId); }
/// <summary> /// Retrieves a collection of comments associated with the photo. /// </summary> /// <returns>A collection of Comment objects.</returns> public Comments GetComments() { if (comments == null) { CommentDB db = new CommentDB(token.DBConnection); comments = db.GetComments(token, this); } return(comments); }
public void DeleteCommentFailed() { int id = 100; int oldNumberOfCommentsByPostId = CommentDB.GetCommentsByPostId(active, 1).Count; CommentDB.DeleteComment(id); int newNumberOfCommentsByPostId = CommentDB.GetCommentsByPostId(active, 1).Count; Assert.AreEqual(oldNumberOfCommentsByPostId, newNumberOfCommentsByPostId); }
public static bool Delete(Comment myComment) { if (myComment != null) { return(CommentDB.Delete(myComment.id)); } else { return(false); } }
public void DeleteCommentFailed() { Guid id = Guid.NewGuid(); int oldNumberOfCommentsByPostId = CommentDB.GetCommentsByPostId(active, post_id).Count; CommentDB.DeleteComment(id); int newNumberOfCommentsByPostId = CommentDB.GetCommentsByPostId(active, post_id).Count; Assert.AreEqual(oldNumberOfCommentsByPostId, newNumberOfCommentsByPostId); }
public ActionResult Comment(int id, string content) { CommentDB com = new CommentDB(); com.student_id = User.Identity.Name; com.item_id = id; com.content = content; com.comment_time = DateTime.Now; comment.Comments.Add(com); comment.SaveChanges(); return(Redirect("/item/detail/" + id)); }
public void InsertCommentFailed() { Comment comment = new Comment { TextComment = "", UserId = "user_1", PostId = "post_1", Active = true }; Assert.IsNull(CommentDB.InsertComment(comment)); }
public void InsertCommentSuccess() { Comment comment = new Comment { TextComment = "new text comment", UserId = "user_1", PostId = "post_1", Active = true }; Assert.IsNotNull(CommentDB.InsertComment(comment)); }
public void UpdateCommentSuccess() { Guid id = CommentDB.GetCommentsByPostId(active, post_id)[0].Id; Comment comment = new Comment { TextComment = "updated text comment", UserId = "user_1", PostId = "post_1", Active = true }; Comment updatedComment = CommentDB.UpdateComment(comment, id); Assert.AreEqual(comment.TextComment, updatedComment.TextComment); }
public void InsertCommentFailed() { Comment comment = new Comment { Text = "", Date = new DateTime(2018, 2, 1, 5, 0, 0), Attachment = Encoding.ASCII.GetBytes("dodatak"), PostId = 3, UserId = 2, Active = true }; Assert.IsNull(CommentDB.InsertComment(comment)); }
public void UpdateCommentFailed() { Guid id = CommentDB.GetCommentsByPostId(active, post_id)[0].Id; Comment comment = new Comment { TextComment = "", UserId = "user_1", PostId = "post_1", Active = true }; Comment updatedComment = CommentDB.UpdateComment(comment, id); Assert.IsNull(updatedComment); }
public object Convert(object value, Type targetType, object parameter, string language) { long commentId = long.Parse(value.ToString()); bool isMyComment = CommentDB.IsMyComment(commentId, App.CurrentUser); if (isMyComment == false) { return(Visibility.Collapsed); } else { return(Visibility.Visible); } }
public async Task <bool> AddCommentToTask(Comment comment) { var commentDb = new CommentDB() { Time = comment.Time, Task = await _databaseContext.Tasks.FindAsync(comment.Task.Id), Text = comment.Text, User = await _databaseContext.Users.FindAsync(comment.User.Id) }; await _databaseContext.Comments.AddAsync(commentDb); await _databaseContext.SaveChangesAsync(); return(true); }
private void CurrentReactionBtn_Click(object sender, RoutedEventArgs e) { string oldReaction = this.CurrentReactionBtn.Tag.ToString(); if (!string.IsNullOrEmpty(oldReaction)) { if (oldReaction.Equals("heart")) { ZComment.Heart -= 1; ZComment.Total -= 1; CommentDB.UpdateHeart(ZComment.CommentId, ZComment.Heart); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, ""); this._myReaction.ReactionType = ""; } if (oldReaction.Equals("happy")) { ZComment.Happy -= 1; ZComment.Total -= 1; CommentDB.UpdateHappy(ZComment.CommentId, ZComment.Happy); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, ""); this._myReaction.ReactionType = ""; } if (oldReaction.Equals("sad")) { ZComment.Sad -= 1; ZComment.Total -= 1; CommentDB.UpdateSad(ZComment.CommentId, ZComment.Sad); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, ""); this._myReaction.ReactionType = ""; } if (oldReaction.Equals("like")) { ZComment.Like -= 1; ZComment.Total -= 1; CommentDB.UpdateLike(ZComment.CommentId, ZComment.Like); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, ""); this._myReaction.ReactionType = ""; } } else { ZComment.Like += 1; ZComment.Total += 1; CommentDB.UpdateLike(ZComment.CommentId, ZComment.Like); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, "like"); this._myReaction.ReactionType = "like"; } }
public void UpdateCommentFailed() { int id = CommentDB.GetCommentsByPostId(active, 3)[0].Id; Comment comment = new Comment { Text = "", Date = new DateTime(2018, 2, 1, 5, 0, 0), Attachment = Encoding.ASCII.GetBytes("dodatak"), PostId = 3, UserId = 2, Active = true }; Comment updatedComment = CommentDB.UpdateComment(comment, id); Assert.IsNull(updatedComment); }
public void UpdateCommentSuccess() { int id = CommentDB.GetCommentsByPostId(active, 3)[0].Id; Comment comment = new Comment { Text = "UPDATE", Date = new DateTime(2018, 2, 1, 5, 0, 0), Attachment = Encoding.ASCII.GetBytes("dodatak"), PostId = 3, UserId = 2, Active = true }; Comment updatedComment = CommentDB.UpdateComment(comment, id); Assert.AreEqual(comment.Text, updatedComment.Text); }
private void Yes_Click(object sender, RoutedEventArgs e) { var tag = (sender as Button).Tag; long commentId = (long)tag; Comment comment = CommentDB.GetComment(commentId); foreach (Comment comm in ViewUserTask.comments) { if (comm.CommentId == commentId) { ViewUserTask.comments.Remove(comm); break; } } CommentDB.RemoveComment(commentId); RemovePopup.IsOpen = false; }
private void HeartBtn_Click(object sender, RoutedEventArgs e) { bool isReacted = CommentDB.IsReacted(ZComment.CommentId, App.CurrentUser); if (isReacted == false) { ZComment.Heart += 1; ZComment.Total += 1; CommentDB.UpdateHeart(ZComment.CommentId, ZComment.Heart); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, "heart"); this._myReaction.ReactionType = "heart"; } else if (isReacted) { string currentReaction = CommentDB.GetReaction(ZComment.CommentId, App.CurrentUser); if (currentReaction.Equals("like")) { ZComment.Like -= 1; ZComment.Total -= 1; CommentDB.UpdateLike(ZComment.CommentId, ZComment.Like); } if (currentReaction.Equals("happy")) { ZComment.Happy -= 1; ZComment.Total -= 1; CommentDB.UpdateHappy(ZComment.CommentId, ZComment.Happy); } if (currentReaction.Equals("sad")) { ZComment.Sad -= 1; ZComment.Total -= 1; CommentDB.UpdateSad(ZComment.CommentId, ZComment.Sad); } if (string.IsNullOrEmpty(currentReaction) || !(currentReaction.Equals("heart"))) { ZComment.Heart += 1; ZComment.Total += 1; CommentDB.UpdateHeart(ZComment.CommentId, ZComment.Heart); CommentDB.AddReaction(ZComment.CommentId, App.CurrentUser, "heart"); this._myReaction.ReactionType = "heart"; } } ReactionsPopup.IsOpen = false; }
private void TextBlock_PointerEntered(object sender, PointerRoutedEventArgs e) { //Windows.UI.Input.PointerPoint point = e.GetCurrentPoint(CountText); //var x = point.Position.X.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); //var y = point.Position.Y.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); //var transform = this.CountText.TransformToVisual(this.ReactionsPanel); //var y= transform.TransformPoint(new Point()).Y + CountText.ActualHeight; // ReactedPeople.HorizontalOffset = Convert.ToDouble(x); int no = Convert.ToInt32(CountText.Text); ReactedPeople.VerticalOffset = -25 - (18.8) * no; ReactedPeople.IsOpen = true; List <Reaction> ReactedUsers = CommentDB.GetReactedUsers(ZComment.CommentId); ReactedPeopleList.ItemsSource = ReactedUsers; //ReactedPeopleList.DataContext = ReactedUsers; }
public ActionResult makeComment(int commentTargetId, string content, int weikeId) { // todo if ((User)Session["user"] != null) { int user_id = ((User)Session["user"]).id; string username = ((User)Session["user"]).name; if (commentTargetId != 0) { Comment parent = CommentDB.FindCommentById(commentTargetId); int parent_userId = parent.user_id; if (user_id == parent_userId) { return(Json(new { success = -1 })); } Notice notice = new Notice(0, user_id, parent_userId, weikeId, "reply", false, DateTime.Now); NoticeDB.Insert(notice); } else { int userId = WeikeDB.FindByWeikeId(weikeId).weike.user_id; Notice notice = new Notice(0, user_id, userId, weikeId, "comment", false, DateTime.Now); NoticeDB.Insert(notice); } DateTime now = DateTime.Now; Comment comment = new Comment(0, user_id, weikeId, now, content, commentTargetId); int comment_id = CommentDB.Insert(comment); return(Json(new { success = 1, commentId = comment_id, username = username, time = now })); } else { return(Json(new { success = 0 })); } // id of the new comment }
public void DeleteComment(int id) { CommentDB.DeleteComment(id); }
public Comment UpdateComment([FromBody] Comment comment, int id) { return(CommentDB.UpdateComment(comment, id)); }
public Comment InsertComment([FromBody] Comment comment) { return(CommentDB.InsertComment(comment)); }
public Comment GetComment(int id) { return(CommentDB.GetComment(id)); }
public IEnumerable <Comment> GetCommentsByPostId(int id, [FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active) { return(CommentDB.GetCommentsByPostId(active, id)); }