public IEnumerable <IAccount> GetAllAccounts() { if (!_isDirty) { return(_cache); } _cache = _storage.GetAllAccounts(); _isDirty = false; return(_cache); }
public CategoryTransactionsReportViewModel(IAccountStorage accountStorage, ICategoryStorage categoryStorage, ITransactionStorage transactionStorage) { _accountStorage = accountStorage ?? throw new ArgumentNullException(nameof(accountStorage)); _categoryStorage = categoryStorage ?? throw new ArgumentNullException(nameof(categoryStorage));; _transactionStorage = transactionStorage ?? throw new ArgumentNullException(nameof(transactionStorage)); _filteredSource = new TransactionFilteredSource(DateTime.Now, DateTime.Now); Accounts = new ObservableCollection <IAccount>(_accountStorage.GetAllAccounts()); Categories = new ObservableCollection <ICategory>(_categoryStorage.MakeFlatCategoryTree()); StartDate = DateTimeOffset.Now; EndDate = StartDate; }
public Report1ViewModel(IAccountStorage accountStorage, ICategoryStorage categoryStorage, ITransactionStorage transactionStorage) { _accountStorage = accountStorage ?? throw new ArgumentNullException(nameof(accountStorage)); _categoryStorage = categoryStorage ?? throw new ArgumentNullException(nameof(categoryStorage));; _transactionStorage = transactionStorage ?? throw new ArgumentNullException(nameof(transactionStorage)); Accounts = new ObservableCollection <IAccount>(_accountStorage.GetAllAccounts()); Account = Accounts.FirstOrDefault(); ReportPeriod = new ObservableCollection <string> { "All period", "Today", "Yesterday", "This Month", "Last Month" }; }
public static IQuickTransaction Convert(IDictionary <string, object> line, IQuickTransactionFactory quickTransactionFactory, IAccountStorage accountStorage, ICategoryStorage categoryStorage) { var id = (long)line["id"]; var accountId = (long)(line["accountId"] is DBNull?0L: line["accountId"]); var categoryId = (long)(line["categoryId"] is DBNull ? 0L : line["categoryId"]); var name = line["name"].ToString(); var total = decimal.Parse(line["total"].ToString()); var account = accountStorage.GetAllAccounts().FirstOrDefault(x => x?.Id == accountId); var category = categoryStorage.GetAllCategories().FirstOrDefault(x => x?.Id == categoryId); var weight = decimal.Parse(line["weight"].ToString()); var askForTotal = (long)line["askForTotal"] > 0; var askForWeight = (long)line["askForWeight"] > 0; var transaction = quickTransactionFactory.CreateQuickTransaction(account, category, name, total, id, weight, askForTotal, askForWeight); transaction.Id = id; return(transaction); }
public static ITransaction Convert(IDictionary <string, object> line, ITransactionFactory transactionFactory, IAccountStorage accountStorage, ICategoryStorage categoryStorage) { var id = (long)line["id"]; var timestamp = DateTime.Parse(line["timestamp"].ToString()); var accountId = (long)(line["accountId"]); var categoryId = (long)(line["categoryId"]); var name = line["name"].ToString(); var total = decimal.Parse(line["total"].ToString()); var account = accountStorage.GetAllAccounts().FirstOrDefault(x => x?.Id == accountId); var category = categoryStorage.GetAllCategories().FirstOrDefault(x => x?.Id == categoryId); var weight = decimal.Parse(line["weight"].ToString()); //var productId = (line["productId"] is System.DBNull)? 0: (long)line["productId"];//Add Product Storage //var parentId = (line["parentId"] is System.DBNull) ? 0 : (long)line["parentId"]; //var isComplexTransaction = (long) line["isComplexTransaction"] > 0; var transaction = (Transaction)transactionFactory.CreateTransaction(account, category, name, total, timestamp, id, weight, null, null); transaction.Id = id; transaction.Timestamp = timestamp; return(transaction); }
private void UpdateList() { _bankAccounts.Clear(); _bankAccounts.AddRange(_bankAccountStorage.GetAllAccounts().Select(account => account.ToBankAccount())); }