예제 #1
0
        public void SetHolding(int accountID, int insID, int lots)
        {
            if (lots == 0)
            {
                return;
            }

            var holds = _da.GetHoldings(accountID);
            var hold  = holds.FirstOrDefault(h => h.InsID == insID);

            if (hold == null && lots != 0)
            {
                Holding h = new Holding();
                h.AccountID = accountID;
                h.InsID     = insID;
                h.LotCount  = lots;
                _da.InsertHolding(h);
            }
            else if (hold != null && lots == 0)
            {
                _da.DeleteHolding(hold.HoldingID);
            }
            else if (hold != null && lots != 0 && hold.LotCount != lots)
            {
                hold.LotCount = lots;
                _da.UpdateHolding(hold);
            }
        }