public void UpdateStorage(BiblosDS.Library.Common.Objects.DocumentStorage Storage) { using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.Storage entityStorage = Storage.TryToConvertTo <Model.Storage>(false); if (entityStorage.EntityKey == null) { entityStorage.EntityKey = db.CreateEntityKey(entityStorage.GetType().Name, entityStorage); } var attachedEntity = db.GetObjectByKey(entityStorage.EntityKey) as Model.Storage; if (Storage.StorageType != null) { entityStorage.IdStorageType = Storage.StorageType.IdStorageType; } if (Storage.Server != null && Storage.Server.IdServer != Guid.Empty) { entityStorage.IdServer = Storage.Server.IdServer; } db.ApplyCurrentValues(entityStorage.EntityKey.EntitySetName, entityStorage); db.SaveChanges(); } }
public Guid AddStorage(BiblosDS.Library.Common.Objects.DocumentStorage Storage) { Storage.IdStorage = Guid.NewGuid(); using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.Storage entityStorage = Storage.TryToConvertTo <Model.Storage>(db); if (Storage.StorageType != null) { entityStorage.IdStorageType = Storage.StorageType.IdStorageType; } if (Storage.Server != null && Storage.Server.IdServer != Guid.Empty) { entityStorage.IdServer = Storage.Server.IdServer; } db.AddToStorage(entityStorage); db.SaveChanges(); } return(Storage.IdStorage); }