Exemplo n.º 1
0
 public static void DeleteComment(Comment comment)
 {
     try
     {
         DB.DB.Comments_Delete(comment.Id);
     }
     catch (Exception e)
     {
         Utils.Log.LogInfo(e.Message, e, "error");
     }
 }
Exemplo n.º 2
0
 public static void UpdateComment(Comment comment)
 {
     try
     {
         var old = GetComment(comment.Id);
         var old_mentions = GetMentions(old.Text);
         var new_mentions = GetMentions(comment.Text);
         new_mentions.ExceptWith(old_mentions);
         foreach (var m in new_mentions)
         {
             var user = DB.DB.GetUser(m);
             if (user.Any())
             {
                 DB.DB.Notification_Insert(Convert.ToInt32(user[0]["id"]), "You've been mentioned in a comment", comment.Code_Id, comment.User_Id);
             }
         }
         DB.DB.Comments_Update(comment.Id, comment.Text);
     }
     catch (Exception e)
     {
         Utils.Log.LogInfo(e.Message, e, "error");
     }
 }
Exemplo n.º 3
0
 public static void SaveComment(Comment comment)
 {
     try
     {
         if (string.IsNullOrEmpty(comment.Text))
         {
             return;
         }
         DB.DB.Comments_Insert(comment.Code_Id, comment.User_Id, comment.Text);
         int? user_id = Model.GetUserIdByCodeId(comment.Code_Id);
         if (user_id != null)
         {
             DB.DB.Notification_Insert((int)user_id, "New comment on your code", comment.Code_Id, comment.User_Id);
         }
         var mentions = GetMentions(comment.Text);
         foreach (var m in mentions)
         {
             var user = DB.DB.GetUser(m);
             if (user.Any())
             {
                 DB.DB.Notification_Insert(Convert.ToInt32(user[0]["id"]), "You've been mentioned in a comment", comment.Code_Id, comment.User_Id);
             }
         }
     }
     catch (Exception e)
     {
         Utils.Log.LogInfo(e.Message, e, "error");
     }
 }