public bool DeleteComment(int commentId) { var comment = commentManager.GetById(commentId); if (Convert.ToInt32(User.Identity.GetUserId()) == comment.UserId) { return(commentManager.Delete(comment) == true ? true : false); } else { return(false); } }
public IActionResult Edit(int?id) { if (id == null) { return(NotFound()); } var comment = commentManager.GetById((int)id); if (comment.OwnerId != userService.GetUserId()) { return(Forbid()); } return(View(comment)); }
public ActionResult DeleteComment(long id) { var comment = _commentManager.GetById(id); _commentManager.Delete(comment); return(RedirectToRoute("ServicePage", new { id = comment.id_service })); }
public RedirectToRouteResult CommentSeen(int?id) { var commentSeen = commentManager.GetById((int)id); var requisition = _requisitionManager.GetById(commentSeen.RequsitionId); commentSeen.ReceiverSeenTime = DateTime.Now; commentSeen.IsReceiverSeen = true; commentManager.Update(commentSeen); return(RedirectToAction("Details_V2", new { id = requisition.Id })); }
/// <summary> /// Metodo que carga los datos de un comentario para poder editarlo /// </summary> /// <param name="id">id del comentario</param> /// <returns>vista</returns> public IActionResult Edit(int id) { try { //verificamos que el id no este vacio if (id != 0) { //obtenemos el malware var comment = commentManager.GetById(id); //si elmalware no esta vacio generamos el model if (comment != null) { //creamos modelo para pasarlo a ala vista var model = new Comment { Id = comment.Id, Malware_Id = comment.Malware_Id, Malware = comment.Malware, User = comment.User, User_Id = comment.User_Id, TextComment = comment.TextComment }; return(View(model)); } //si el malware no existe redirigimos a index else { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } } catch (Exception ex) { //guardamos log si se produce excepcion _log.LogError(ex.Message, ex); return(RedirectToAction("Index")); } }
public ActionResult DeleteComment(int commentId, string gameKey) { var comment = _commentManager.GetById(commentId); comment.IsDeleted = true; _commentManager.EditComment(comment); var childComments = _commentManager.FindByParentId(comment.Id).Where(c => c.IsQuote); childComments.ForEach(c => c.Quote = messageForDeletedQuote); childComments.ForEach(c => _commentManager.EditComment(c)); return(RedirectToAction("GetAllCommentsByGameKey", "Comment", new { gameKey })); }
public Comment Get(int id) { return(_commentManager.GetById(id)); }