Exemple #1
0
        public static Store CreateStore(ProjectSIAEntities db, string name, DateTime beginDate, DateTime endDate, StoreType type, StoreRule rule, double value)
        {
            using (var wl = new WriteLock())
            {
                if (endDate <= beginDate)
                    throw new AutistarException("종료일이 시작일보다 빠릅니다.");

                var newStore = db.Store.Add(new ProjectSIA.Store { name = name, beginDate = beginDate, endDate = endDate, type = type.ToString(), rule = rule.ToString(), value = value });
                var rows = db.SaveChanges();
                if (rows != 1)
                    throw new AutistarException("행사장(거래처) 추가 중 DB 작업이 실패했습니다.");
                var store = new Store(newStore);
                _storeList.Add(store);
                return store;
            }
        }
Exemple #2
0
 public static Store GetLocalStore(ProjectSIAEntities db)
 {
     using (var rl = new ReadLock())
     {
         var localStore = GetAllStoreList(db).Where(x => x.Type == StoreType.Local).FirstOrDefault();
         if (localStore == null)
         {
             using (var wl = new WriteLock())
             {
                 var dbLocalStore = db.Store.Add(new ProjectSIA.Store() { name = "사무실", beginDate = new DateTime(2012, 1, 1), endDate = DateTime.MaxValue, type = StoreType.Local.ToString(), rule = StoreRule.None.ToString(), value = 0 });
                 var rows = db.SaveChanges();
                 if (rows != 1)
                     throw new AutistarException("사무실 Store를 만드는 과정 중 DB 작업을 실패했습니다.");
                 localStore = new Store(dbLocalStore);
             }
         }
         return localStore;
     }
 }