Example #1
0
        public void CreateItem(IItemModel t)
        {
            try
            {
                using (ItemEntities context = ItemEntities.Instance())
                {
                    context.AddToItems((Item)t);
                    context.SaveChanges();

                    DataCache.RemoveCache(itemCacheKey(t.ModuleId));
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }
Example #2
0
        public void DeleteItem(int itemId, int moduleId)
        {
            try
            {
                using (ItemEntities context = ItemEntities.Instance())
                {
                    var delItem = GetItem(itemId, false, context);
                    context.DeleteObject(delItem);
                    context.SaveChanges();

                    DataCache.RemoveCache(itemCacheKey(moduleId));
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }
Example #3
0
 public void UpdateItem(IItemModel t)
 {
     try
     {
         using (ItemEntities context = ItemEntities.Instance())
         {
             System.Data.EntityKey pKey = ((Item)t).EntityKey;
             if (pKey != null)
             {
                 object pObject;
                 if (context.TryGetObjectByKey(pKey, out pObject))
                 {
                     context.ApplyPropertyChanges(pKey.EntitySetName, (Item)t);
                 }
             }
             context.SaveChanges();
         }
         DataCache.RemoveCache(itemCacheKey(t.ModuleId));
     }
     catch (Exception ex)
     {
         Exceptions.LogException(ex);
     }
 }