private int InsertUpdate(Tag entity, int? userId, DbActionType action, bool intoCache) { var cache = new CacheWrapper(); var res = TagsDataAdapter.InsertUpdate(entity, userId, action); if (res == 0) { //if ok - update cache if (intoCache) { if (action == DbActionType.Insert) cache.AddToList(CacheKey, entity, userId); if (action == DbActionType.Update) cache.UpdateList(CacheKey, entity, userId); } } return res; }
public virtual int ChangeBalance(int? accountId, int? companyId, decimal value) { var res = AccountsDataAdapter.ChangeBalance(accountId, companyId, value); var cache = new CacheWrapper(); if (res == 0) { Account account = cache.GetFromList(CacheKey, new Account() { Id = accountId }, companyId); if (account != null) { account.Balance = account.Balance + value; cache.UpdateList(CacheKey, account, companyId); } } return res; }
private static int InsertUpdate(Account entity, int? companyId, DbActionType action, bool intoCache) { var cache = new CacheWrapper(); var res = AccountsDataAdapter.InsertUpdate(entity, companyId, action); if (res == 0) { //if ok - update cache if (intoCache) { if (action == DbActionType.Insert) cache.AddToList(CacheKey, entity, companyId); if (action == DbActionType.Update) cache.UpdateList(CacheKey, entity, companyId); } } return res; }