Beispiel #1
0
        /// <summary>
        /// Insert new Cashflow object into db
        /// </summary>
        /// <param name="cashflow">Cashflow object (CashflowID = 0)</param>
        /// <returns>New Id (also set CashflowID)</returns>
        public int InsertCashflow(CommonData.Cashflow cashflow)
        {
            Cashflow db_cashflow = new Cashflow()
            {
                CashflowID = cashflow.CashflowID,
                Summa      = cashflow.Summa,
                Time       = StorageLib.ToDbTime(cashflow.Time),
                TradeID    = cashflow.TradeID,
                Spend      = (byte)cashflow.Spend,
                AccountID  = cashflow.AccountID
            };

            _da.DbContext.Insert(db_cashflow);
            cashflow.CashflowID = db_cashflow.CashflowID;

            return(cashflow.CashflowID);
        }
Beispiel #2
0
        /// <summary>
        /// Get Cashflows by account Id
        /// </summary>
        /// <param name="accountID">Account Id</param>
        /// <returns>Cashflows list</returns>
        public IEnumerable <CommonData.Cashflow> GetCashflows(int accountID)
        {
            List <CommonData.Cashflow> cashflows = new List <CommonData.Cashflow>();

            var db_cashflows = _da.DbContext.Table <Cashflow>().Where(r => r.AccountID == accountID).ToList();

            foreach (var db_cashflow in db_cashflows)
            {
                var cashflow = new CommonData.Cashflow()
                {
                    CashflowID = db_cashflow.CashflowID,
                    Summa      = db_cashflow.Summa,
                    Time       = StorageLib.ToDateTime(db_cashflow.Time),
                    TradeID    = db_cashflow.TradeID,
                    Spend      = (CashflowSpend)db_cashflow.Spend,
                    AccountID  = db_cashflow.AccountID
                };
                cashflows.Add(cashflow);
            }

            return(cashflows);
        }