private int UpdateMovieActorsMapping(List <int> actorsToRemove, List <Actor> newActors, out StringBuilder errors) { errors = new StringBuilder(); int count = 0; int errorCount = 0; try { if (actorsToRemove.Any()) { count = _mappingService.RemoveBatchMovieActorsMap(_currentMovie.Id, actorsToRemove); if (count != actorsToRemove.Count) { errorCount++; errors.Append($"\nFailed to unmap {actorsToRemove.Count - count} out of {actorsToRemove.Count} previous actors"); } } } catch (Exception ex) { errorCount++; errors.Append($"\nFailed to unmap previous actors"); } try { if (newActors.Any()) { count = _mappingService.AddBatchMovieActorMap(_currentMovie, newActors); if (count != newActors.Count) { errorCount++; errors.Append($"\nFailed to map {newActors.Count - count} out of {newActors.Count} new actors to movie"); } } } catch (Exception ex) { errorCount++; errors.Append("\nFailed to map actors to movie"); } return(errorCount); }