/// <summary> /// Update cash object /// </summary> /// <param name="cash">Cash object (CashID > 0)</param> public void UpdateCash(CommonData.Cash cash) { using (var db = new DaContext(_options)) { db.Update(cash); db.SaveChanges(); } }
/// <summary> /// Update cash object /// </summary> /// <param name="cash">Cash object (CashID > 0)</param> public void UpdateCash(CommonData.Cash cash) { Cash db_cash = new Cash() { CashID = cash.CashID, Initial = cash.Initial, AccountID = cash.AccountID, Current = cash.Current, Sell = cash.Sell, Buy = cash.Buy, SellComm = cash.SellComm, BuyComm = cash.BuyComm }; _da.DbContext.Update(db_cash); }
/// <summary> /// Insert new Cash object into db /// </summary> /// <param name="cash">Cash object (CashID = 0)</param> /// <returns>New cash Id (also set CashID)</returns> public int InsertCash(CommonData.Cash cash) { Cash db_cash = new Cash() { CashID = cash.CashID, Initial = cash.Initial, AccountID = cash.AccountID, Current = cash.Current, Sell = cash.Sell, Buy = cash.Buy, SellComm = cash.SellComm, BuyComm = cash.BuyComm }; _da.DbContext.Insert(db_cash); cash.CashID = db_cash.CashID; return(cash.CashID); }
/// <summary> /// Get cashes by account Id /// </summary> /// <param name="accountID">account Id</param> /// <returns>Cashes list</returns> public IEnumerable <CommonData.Cash> GetCashes(int accountID) { List <CommonData.Cash> cashes = new List <CommonData.Cash>(); var db_cashes = _da.DbContext.Table <Cash>().Where(r => r.AccountID == accountID).ToList(); foreach (var db_cash in db_cashes) { var cash = new CommonData.Cash() { CashID = db_cash.CashID, Initial = db_cash.Initial, AccountID = db_cash.AccountID, Current = db_cash.Current, Sell = db_cash.Sell, Buy = db_cash.Buy, SellComm = db_cash.SellComm, BuyComm = db_cash.BuyComm }; cashes.Add(cash); } return(cashes); }