//public void DownLoadCatalogs(Catalogs catalogs) //{ // if (catalogs?.Items != null && catalogs.Items.Any()) // { // catalogRepository.Load(catalogs.Items.Select(x => x.Id)); // photoRepository.Load(catalogs.Items.SelectMany(x => x.Photos)); // dataService.DataBaseContext.Configuration.AutoDetectChangesEnabled = false; // dataService.DataBaseContext.Configuration.ValidateOnSaveEnabled = false; // var entities = new List<CatalogItemEntity>(); // catalogs.Items.ToList().ForEach( // x => // { // try // { // CatalogItemEntity oldCatalogItem = GetCatalogItem(x.Id); // if (oldCatalogItem != null) // { // Update(oldCatalogItem, x); // } // else // { // entities.Add(Create(x)); // } // } // catch (Exception e) // { // ; // } // }); // if (entities.Any()) // { // dataService.InsertMany(entities); // } // else // { // dataService.DataBaseContext.SaveChanges(); // } // long[] ids = // catalogs.Items // .Where(x => GetCatalogItem(x.Id) != null) // .Select(x => x.Id) // .ToArray(); // webService.ConfirmUpdateCatalogs(ids); // dataService.DataBaseContext.Configuration.AutoDetectChangesEnabled = true; // dataService.DataBaseContext.Configuration.ValidateOnSaveEnabled = true; // } //} #endregion #region Directory private DirectoryEntity GetDirectory(long id, List <DirectoryEntity> cacheDirectoryEntity) { DirectoryEntity directory = directoryRepository.GetItem(id); if (directory == null) { directory = dataService.DataBaseContext.DirectoryEntities.Find(id); if (directory != null) { cacheDirectoryEntity.Add(directory); } } return(directory); }