Exemplo n.º 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));
     }
 }
Exemplo n.º 4
0
 public TComments UpdateComment(TComments comment)
 {
     Context.TComments.Update(comment);
     Context.SaveChanges();
     return(Context.TComments.Find(comment.TCommentId));
 }
Exemplo n.º 5
0
 public void RemoveComment(TComments comment)
 {
     comment.Deleted = true;
     Context.TComments.Update(comment);
     Context.SaveChanges();
 }
Exemplo n.º 6
0
 public void AddComment(TComments comment)
 {
     Context.TComments.Add(comment);
     Context.SaveChanges();
 }