Ejemplo n.º 1
0
        private static IPositionTransferDetail assignProperties(TransferPositionDetailsEditView updateInput, IPositionTransferDetail updatingLine, IDalSession session)
        {
            IInstrument instrument = InstrumentMapper.GetInstrument(session, updateInput.Instrumentid);

            updatingLine.TxDirection = updateInput.TxDirection;

            updatingLine.PositionSize = new InstrumentSize(updateInput.PositionSize, instrument);

            updatingLine.ActualPrice = getPriceForInstrument(session, ((ITradeableInstrument)instrument), updatingLine.ParentTransfer.TransferDate);

            if((updateInput.TransferPriceQuantity != 0m))
                updatingLine.TransferPrice = new Price(updateInput.TransferPriceQuantity, ((ITradeableInstrument)instrument).CurrencyNominal, instrument);
            else
                updatingLine.TransferPrice = updatingLine.ActualPrice;

            updatingLine.ValueVV = updatingLine.PositionSize.CalculateAmount(updatingLine.TransferPrice);
            updatingLine.ValueinEuro = updatingLine.ValueVV.CurrentBaseAmount;

            return updatingLine;
        }
Ejemplo n.º 2
0
        public static bool UpdatePositionTransferDetails(TransferPositionDetailsEditView updateInput)
        {
            IDalSession session = NHSessionFactory.CreateSession();

            try
            {
                IPositionTransfer transfer = PositionTransferMapper.getTransfer(session, updateInput.ParentTransfer);
                IPositionTransferDetail updatingLine = null;

                if (updateInput.Key == 0)
                    updatingLine = new PositionTransferDetail() { ParentTransfer = transfer };
                else
                    updatingLine = PositionTransferMapper.getTransferDetail(session, updateInput.Key);

                updatingLine = assignProperties(updateInput, updatingLine, session);

                return session.InsertOrUpdate(updatingLine);

            }

            finally
            {
                session.Close();
            }
        }