Example #1
0
 public static void Initial()
 {
     _SchoolItemCache = SchoolItemAccessor.SelectAll()
                        .OrderByDescending(c => c.Sort)
                        .ThenByDescending(c => c.UpdateTime)
                        .ToList();
 }
Example #2
0
        public static void Remove(SchoolItem SchoolItem)
        {
            //更新資料庫
            SchoolItemAccessor.Delete(SchoolItem);

            //更新記憶体
            _SchoolItemCache.Remove(SchoolItem);
        }
Example #3
0
        public static void Save(SchoolItem SchoolItem)
        {
            lock (SaveObject)
            {
                if (SchoolItem.Id == "-1")
                {
                    SchoolItem.Id = Guid.NewGuid().ToString();
                }

                SchoolItem.UpdateTime = DateTime.Now;

                //更新資料庫
                SchoolItemAccessor.UpdateInsert(SchoolItem);

                //更新記憶體
                _SchoolItemCache.Remove(SchoolItem);
                _SchoolItemCache.Add(SchoolItem);

                _SchoolItemCache.OrderBy(b => b.Id)
                .ThenByDescending(c => c.CreateTime)
                .ToList();
            }
        }