public void Save(Playlists viewModel) { using (_busyStack.GetToken()) { foreach (var item in viewModel.Items) { Save(item); } } }
public void Save(Playlists playlists, bool isRoot = true) { using (_busyStack.GetToken()) { var saveRequired = false; for (var i = 0; i < playlists.Items.Count; i++) { saveRequired = true; Save(playlists.Items[i], false); if (i % _saveThreshold == 0) { _context.SaveChanges(); saveRequired = false; } } if (isRoot || saveRequired) { _context.SaveChanges(); } } }