public Task <Either <ActionResult, Unit> > DeleteRelease(Guid releaseId) { return(_persistenceHelper .CheckEntityExists <Release>(releaseId) .OnSuccess(_userService.CheckCanDeleteRelease) .OnSuccessDo(async() => await _releaseDataFileService.DeleteAll(releaseId)) .OnSuccessDo(async() => await _releaseFileService.DeleteAll(releaseId)) .OnSuccessVoid(async release => { var roles = await _context .UserReleaseRoles .Where(r => r.ReleaseId == releaseId) .ToListAsync(); var invites = await _context .UserReleaseInvites .Where(r => r.ReleaseId == releaseId) .ToListAsync(); release.SoftDeleted = true; roles.ForEach(r => r.SoftDeleted = true); invites.ForEach(r => r.SoftDeleted = true); _context.Update(release); _context.UpdateRange(roles); _context.UpdateRange(invites); await _context.SaveChangesAsync(); await _releaseSubjectService.SoftDeleteAllReleaseSubjects(releaseId); })); }
public async Task DeletePreviousVersionsStatisticalData(params Guid[] releaseIds) { var releases = await GetAmendedReleases(releaseIds); var previousVersions = releases.Select(r => r.PreviousVersionId) .Where(id => id.HasValue) .Cast <Guid>() .ToList(); foreach (var previousVersion in previousVersions) { await _releaseSubjectService.SoftDeleteAllReleaseSubjects(previousVersion); } // Remove Statistical Releases for each of the Content Releases await RemoveStatisticalReleases(previousVersions); await _statisticsDbContext.SaveChangesAsync(); }