Example #1
0
 public GenericResponse <TComments> UpdateComment(TComments comment)
 {
     try
     {
         if (comment == null)
         {
             return(new GenericResponse <TComments>("Comment is empty"));
         }
         var commentUpd = CommentRepository.UpdateComment(comment);
         return(new GenericResponse <TComments>(commentUpd));
     }
     catch (Exception ex)
     {
         return(new GenericResponse <TComments>(ex.Message));
     }
 }
 public IActionResult RemoveComment(TComments comment)
 {
     try
     {
         var result = CommentService.RemoveComment(comment);
         if (result.Success)
         {
             return(Ok(result));
         }
         else
         {
             return(BadRequest(result.Message));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IActionResult AddComments(TComments comment)
 {
     try
     {
         var response = CommentService.AddComment(comment);
         if (response.Success)
         {
             return(Ok(response));
         }
         else
         {
             return(BadRequest(response.Message));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #4
0
 public TComments UpdateComment(TComments comment)
 {
     Context.TComments.Update(comment);
     Context.SaveChanges();
     return(Context.TComments.Find(comment.TCommentId));
 }
Example #5
0
 public void RemoveComment(TComments comment)
 {
     comment.Deleted = true;
     Context.TComments.Update(comment);
     Context.SaveChanges();
 }
Example #6
0
 public void AddComment(TComments comment)
 {
     Context.TComments.Add(comment);
     Context.SaveChanges();
 }