public MultistepActionStepResult Step(int step) { var site = SiteRepository.GetById(SiteId); if (site == null) { throw new ApplicationException(string.Format(SiteStrings.SiteNotFound, SiteId)); } var deletedContentsIds = ContentRepository.BatchRemoveContents(SiteId, ITEMS_PER_STEP); var deletedContentsStrIds = new HashSet <string>(deletedContentsIds.Select(id => id.ToString()), StringComparer.InvariantCultureIgnoreCase); var sitePath = site.BasePathInfo.GetSubPathInfo("contents").Path; if (Directory.Exists(sitePath)) { foreach (var sd in new DirectoryInfo(sitePath).EnumerateDirectories().Where(i => deletedContentsStrIds.Contains(i.Name))) { sd.Delete(true); } } return(new MultistepActionStepResult { ProcessedItemsCount = ITEMS_PER_STEP }); }