public CommentViewModel SaveComment(CommentViewModel model) { if (model == null) { throw new ArgumentNullException("model"); } Comment comment; if (model.Id == 0) { comment = this._commentManager.AddComment(model.EntityTypeId, model.Map <Comment>()); } else { comment = this._commentManager.EditComment(model.Map <Comment>()); } this._dataSource.SaveChanges(); var userId = StrixPlatform.User.Id; var isAdmin = StrixPlatform.User.IsAdministrator; var hasChildren = this._commentManager.HasChildComments(comment.Id); model = comment.Map <CommentViewModel>(); model.CanEdit = !hasChildren && (userId == comment.CreatedByUserId || isAdmin); model.CanDelete = !hasChildren && (userId == comment.CreatedByUserId || isAdmin); model.CanRespond = userId != Guid.Empty; return(model); }
public bool DeleteComment(CommentViewModel model) { if (model == null) { throw new ArgumentNullException("model"); } var result = this._commentManager.DeleteComment(model.Map<Comment>(), model.EntityTypeId); this._dataSource.SaveChanges(); return result; }
public bool DeleteComment(CommentViewModel model) { if (model == null) { throw new ArgumentNullException("model"); } var result = this._commentManager.DeleteComment(model.Map <Comment>(), model.EntityTypeId); this._dataSource.SaveChanges(); return(result); }
public CommentViewModel SaveComment(CommentViewModel model) { if (model == null) { throw new ArgumentNullException("model"); } Comment comment; if (model.Id == 0) { comment = this._commentManager.AddComment(model.EntityTypeId, model.Map<Comment>()); } else { comment = this._commentManager.EditComment(model.Map<Comment>()); } this._dataSource.SaveChanges(); var userId = StrixPlatform.User.Id; var isAdmin = StrixPlatform.User.IsAdministrator; var hasChildren = this._commentManager.HasChildComments(comment.Id); model = comment.Map<CommentViewModel>(); model.CanEdit = !hasChildren && (userId == comment.CreatedByUserId || isAdmin); model.CanDelete = !hasChildren && (userId == comment.CreatedByUserId || isAdmin); model.CanRespond = userId != Guid.Empty; return model; }