public Guid AddArchive(BiblosDS.Library.Common.Objects.DocumentArchive Archive) { Archive.IdArchive = Guid.NewGuid(); using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.Archive entityArchive = Archive.TryToConvertTo <Model.Archive>(db); db.AddToArchive(entityArchive); db.SaveChanges(); } return(Archive.IdArchive); }
internal void DeleteArchive(DocumentArchive archiveToClone) { using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.Archive entityArchive = db.Archive.Where(x => x.IdArchive == archiveToClone.IdArchive).SingleOrDefault(); if (entityArchive != null) { db.Archive.DeleteObject(entityArchive); db.SaveChanges(); } } }
public void UpdateArchive(BiblosDS.Library.Common.Objects.DocumentArchive Archive) { using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString)) { Model.Archive entityArchive = Archive.TryToConvertTo <Model.Archive>(false); if (entityArchive.EntityKey == null) { entityArchive.EntityKey = db.CreateEntityKey(entityArchive.GetType().Name, entityArchive); } var attachedEntity = db.GetObjectByKey(entityArchive.EntityKey) as Model.Archive; db.ApplyCurrentValues(entityArchive.EntityKey.EntitySetName, entityArchive); db.SaveChanges(); } }