Пример #1
0
        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);
        }
Пример #2
0
        public void TestInitialize()
        {
            _testTransactionScope = new TransactionScope();

            Target = new rawStorageAccessor();
            CreatedDataContractInstance = new rawStorage();

            _record = Staging.CreateTestRawStorage();
        }
Пример #3
0
        public static rawStorage CreateTestRawStorage()
        {
            var returnVar = new rawStorage
            {
                TheBlob  = "THE BLOB IS THE BLOB",
                addedBy  = "Chris",
                isActive = 1
            };

            return(returnVar);
        }
Пример #4
0
        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);
        }
Пример #5
0
 public void SetupUpdateOrCreate(rawStorage entity)
 {
     //Logger.Log(string.Format(Properties.Resources.Accessors_Updating, typeof(ReportRecord).Name, entity.Id), TraceEventType.Verbose);
 }