public async Task <AditLog> UploadNewAditLogAsync(AditLog aditLog, CancellationToken ct = default) { await _context.FeedAditLogs.AddAsync(aditLog, ct); await _context.SaveChangesAsync(ct); return(await GetAditLogAsync(aditLog.AditLogId, ct)); }
public async Task MarkAditLogAsDeletedAsync(int aditLogId, CancellationToken ct = default) { AditLog aditlog = await _context.FeedAditLogs.FindAsync(aditLogId); aditlog.IsDeleted = true; _context.Update(aditlog); await _context.SaveChangesAsync(ct); }
public async Task <IActionResult> CreateNewAditLog([FromBody] AditLog aditLog, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } return(Ok(await _feedService.UploadNewAditLogAsync(aditLog, ct))); }
public async Task WatchAditLogAsync(int aditLogId, string userUUID, CancellationToken ct = default) { AditLog aditLog = await _context.FeedAditLogs.FindAsync(aditLogId); if (aditLog != null) { aditLog.AditLogViews += 1; _context.Update(aditLog); await _context.SaveChangesAsync(ct); } return; }
public async Task <AditLog> GetAditLogAsync(int aditLogId, CancellationToken ct = default) { AditLog aditLog = await _context.FeedAditLogs .AsNoTracking() .Include(al => al.AditLogTeam) .Include(al => al.Poster) .FirstOrDefaultAsync(al => al.AditLogId == aditLogId); aditLog.PosterDTO = aditLog.Poster.ConvertToDTO(); aditLog.Poster = null; return(aditLog); }
public async Task <IActionResult> DeleteAditLog(int aditLogId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } AditLog aditLog = await _feedService.GetAditLogAsync(aditLogId); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, aditLog.PosterUUID)) { return(Unauthorized("You do not have access to modify this Adit Log")); } await _feedService.MarkAditLogAsDeletedAsync(aditLogId, ct); return(Ok()); }