public async Task <bool> AddAsync(SporeServerAsset asset, SporeServerUser author, string comment) { try { var assetComment = new SporeServerAssetComment() { Author = author, Asset = asset, // comments on your own creations are automatically approved Approved = (author.Id == asset.AuthorId), Timestamp = DateTime.Now, Comment = comment }; await _context.AssetComments.AddAsync(assetComment); await _context.SaveChangesAsync(); _logger.LogInformation($"AddAsync: Added Comment {assetComment.CommentId}"); return(true); } catch (Exception e) { _logger.LogError($"AddAsync: Failed To Add Comment For {asset.AssetId}: {e}"); return(false); } }
public async Task <bool> RemoveAsync(SporeServerAssetComment comment) { try { _context.AssetComments.Remove(comment); await _context.SaveChangesAsync(); _logger.LogInformation($"RemoveAsync: Removed Comment {comment.CommentId}"); return(true); } catch (Exception e) { _logger.LogError($"RemoveAsync: Failed To Remove Comment {comment.CommentId}: {e}"); return(false); } }
public async Task <bool> ApproveAsync(SporeServerAssetComment comment) { try { // set approved flag comment.Approved = true; _context.AssetComments.Update(comment); await _context.SaveChangesAsync(); _logger.LogInformation($"ApproveAsync: Approved Comment {comment.CommentId}"); return(true); } catch (Exception e) { _logger.LogError($"ApproveAsync: Failed To Approve Comment {comment.CommentId}: {e}"); return(false); } }