public void UpdateStorageArea(DocumentStorageArea StorageArea) { using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.StorageArea entityAttribute = StorageArea.TryToConvertTo <Model.StorageArea>(false); if (entityAttribute.EntityKey == null) { entityAttribute.EntityKey = db.CreateEntityKey(entityAttribute.GetType().Name, entityAttribute); } var attachedEntity = db.GetObjectByKey(entityAttribute.EntityKey) as Model.StorageArea; if (StorageArea.Status != null && StorageArea.Status.IdStatus > 0) { entityAttribute.IdStorageStatus = StorageArea.Status.IdStatus; } if (StorageArea.Storage != null) { entityAttribute.IdStorage = StorageArea.Storage.IdStorage; } if (StorageArea.Archive != null) { entityAttribute.IdArchive = StorageArea.Archive.IdArchive; } db.ApplyCurrentValues(entityAttribute.EntityKey.EntitySetName, entityAttribute); db.SaveChanges(); } }
public Guid AddStorageArea(DocumentStorageArea StorageArea) { StorageArea.IdStorageArea = Guid.NewGuid(); using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.StorageArea entityAttribute = StorageArea.TryToConvertTo <Model.StorageArea>(false); if (StorageArea.Status != null && StorageArea.Status.IdStatus > 0) { entityAttribute.IdStorageStatus = StorageArea.Status.IdStatus; } if (StorageArea.Storage != null) { entityAttribute.IdStorage = StorageArea.Storage.IdStorage; } if (StorageArea.Archive != null) { entityAttribute.IdArchive = StorageArea.Archive.IdArchive; } db.AddToStorageArea(entityAttribute); db.SaveChanges(); } return(StorageArea.IdStorageArea); }