private void ClearList(IProjectListItemService service) { using (var scope = new TransactionScope()) { service.DeleteItemsByList(listId); service.BeginTransactionAndCommit(scope); } }
private void AddNewItems(IProjectListItemService service, HashSet <Guid> portfolioProjectIds) { var order = 0; var skip = 0; while (true) { var projectIds = portfolioProjectIds.Skip(tickCount * skip++).Take(tickCount); if (projectIds.Count() == 0) { break; } using (var scope = new TransactionScope()) { var items = new List <ProjectListItem>(); foreach (var newProjectId in projectIds) { items.Add(new ProjectListItem { ProjectListId = listId, ProjectId = newProjectId, Order = order++ }); } service.CreateItems(items); service.BeginTransactionAndCommit(scope); lock (locker) { updatedCount += tickCount; Monitor.PulseAll(locker); } } } }