public static List<Company> GetCompanies(int? userId, bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<Company>(CacheKey, userId); if (res == null || forceSqlLoad) { res = new List<Company>(); using (var holder = SqlConnectionHelper.GetConnection()) { using (var cmd = holder.Connection.CreateSPCommand("companies_get")) { cmd.Parameters.AddWithValue("@id_user", userId); try { using (var reader = cmd.ExecuteReader()) { while (reader.Read()) res.Add(new Company(reader)); } } catch (SqlException e) { cmd.AddDetailsToException(e); throw; } } } //save to cache cache.SetList(CacheKey, res, userId); } return res; }
public static List<FinanceInstitutionLinkToAccount> GetLinksToAccount(bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<FinanceInstitutionLinkToAccount>(CacheKeyLink); if (res == null || forceSqlLoad) { res = FinanceInstitutionDataAdapter.GetLinksToAccount(); //save to cache cache.SetList(CacheKeyLink, res); } return res; }
public static List<Account> GetAccounts(int? companyId, bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<Account>(CacheKey, companyId); if (res == null || forceSqlLoad) { //load from DB res = AccountsDataAdapter.GetAccounts(companyId); //save to cache cache.SetList(CacheKey, res, companyId); } return res; }
public virtual List<Tag> GetAll(int? userId, bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<Tag>(CacheKey, userId); if (res == null || forceSqlLoad) { //load from DB res = TagsDataAdapter.GetTags(userId); //save to cache cache.SetList(CacheKey, res, userId); } return res; }
public virtual List<Category> GetAll(int? userId, bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<Category>(CacheKey, userId); if (res == null || forceSqlLoad) { //load from DB res = CategoriesDataAdapter.GetCategories(userId); //save to cache cache.SetList(CacheKey, res, userId); } //Localize var rm = new ResourceManager(typeof(Resources.Dicts)); foreach (var item in res) { var st = rm.GetString("c_" + item.Id.ToString()); if (!String.IsNullOrEmpty(st)) item.Name = st; } //end Localize return res; }
public virtual IEnumerable<Transaction> GetTransactions(int? companyId, bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<Transaction>(CacheKey, companyId); if (res == null || forceSqlLoad) { //load from DB res = TransactionsDataAdapter.GetTransactions(companyId); //save to cache cache.SetList(CacheKey, res, companyId); } return res; }
public List<string> GetRolesForUser(string username, bool forceSqlLoad) { if (username.Length < 1) { return null; } var cache = new CacheWrapper(); var res = cache.GetList<string>("user_roles_" + username); if (res == null || forceSqlLoad) { //load from DB res = RoleDataAdapter.GetRolesForUser(username); //save to cache cache.SetList("user_roles_" + username, res); } return res; }
public virtual List<CategoryMerchant> GetMerchantsCategories(bool forceSqlLoad) { var cache = new CacheWrapper(); var res = cache.GetList<CategoryMerchant>(MerchCacheKey); if (res == null || forceSqlLoad) { //load from DB res = CategoriesDataAdapter.GetCategoriesMerchant(); //save to cache cache.SetList(MerchCacheKey, res); } //end Localize return res; }