public rawStorage UpdateOrCreate(rawStorage entity) { SetupUpdateOrCreate(entity); rawStorage existing; using (var db = new Db()) { existing = db.Set <rawStorage>().Find(entity.rawStorageID); } if (existing == null) { //-- Insert -- entity = Create(entity); entity.dateAdded = DateTime.UtcNow; } else { //-- Update -- entity.dateLastUpdated = DateTime.UtcNow; using (var db = new Db()) { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } return(entity); }
public void TestInitialize() { _testTransactionScope = new TransactionScope(); Target = new rawStorageAccessor(); CreatedDataContractInstance = new rawStorage(); _record = Staging.CreateTestRawStorage(); }
public static rawStorage CreateTestRawStorage() { var returnVar = new rawStorage { TheBlob = "THE BLOB IS THE BLOB", addedBy = "Chris", isActive = 1 }; return(returnVar); }
public rawStorage Create(rawStorage entity) { entity.dateAdded = DateTime.UtcNow; entity.dateLastUpdated = DateTime.UtcNow; using (var db = new Db()) { db.Set <rawStorage>().Add(entity); db.SaveChanges(); } return(entity); }
public void SetupUpdateOrCreate(rawStorage entity) { //Logger.Log(string.Format(Properties.Resources.Accessors_Updating, typeof(ReportRecord).Name, entity.Id), TraceEventType.Verbose); }