Ejemplo n.º 1
0
        public void AddArchiveStorage(BiblosDS.Library.Common.Objects.DocumentArchiveStorage ArchiveStorage)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.ArchiveStorage entityArchiveStorage = ArchiveStorage.TryToConvertTo <Model.ArchiveStorage>(db);

                if (ArchiveStorage.Storage != null)
                {
                    entityArchiveStorage.IdStorage = ArchiveStorage.Storage.IdStorage;
                    //entityArchiveStorage.StorageReference.TryToAttach(new Model.Storage { IdStorage = ArchiveStorage.Storage.IdStorage }, db);
                }
                else
                {
                    throw new Exceptions.ArchiveStorage_Exception("Storage non valorizzato");
                }

                if (ArchiveStorage.Archive != null)
                {
                    entityArchiveStorage.IdArchive = ArchiveStorage.Archive.IdArchive;
                    //entityArchiveStorage.ArchiveReference.TryToAttach(new Model.Archive { IdArchive = ArchiveStorage.Archive.IdArchive }, db);
                }
                else
                {
                    throw new Exceptions.ArchiveStorage_Exception("Archivio non valorizzato");
                }

                //if (ArchiveStorage. != null)
                //    entityStorage.StorageTypeReference.TryToAttach(new Model.StorageType { IdStorageType = ArchiveStorage.StorageType.IdStorageType }, db);

                db.AddToArchiveStorage(entityArchiveStorage);
                db.SaveChanges();
            }
        }