public BuyAndHoldRawTransactionViewModel MapDtoToViewModel(BuyAndHoldRawTransactionDto dto)
        {
            var viewModel = new BuyAndHoldRawTransactionViewModel
            {
                Id = dto.Id,
                Xref = dto.Xref.ToString(),
                OriginalRawTransactionId = dto.OriginalRawTransactionId.ToString(),
                TransactionDate = dto.TransactionDate.ToShortDateString(),
                SecurityId = dto.SecurityId.ToString(),
                TickerSymbol = dto.TickerSymbol,
                //OriginalSymbol = dto.OriginalTickerSymbol,
                //OriginalSecurityId = dto.OriginalSecurityId.ToString(),
                Company = dto.Company,
                Description = dto.Description,
                Quantity = dto.Quantity,
                Price = dto.Price,
                Amount = dto.Amount,
                Fee = dto.Fees,
                Credit = dto.DebitCredit,
                SuspectedType = dto.SuspectedType,
                Period = dto.Period,
                //TransactionType = dto.TransactionType,
                TransactionTypeId = dto.TransactionTypeId,
                TransactionApplied = dto.TransactionApplied.ToString(),
                DividendAmount = dto.DividendAmount.ToString(),
                AmountInvested = dto.AmountInvested.ToString(),
                NumberShares = dto.NumberShares.ToString(),
                BuyPrice = dto.BuyPrice.ToString(),
                Split = dto.Split,
                ValidFrom = dto.ValidFrom.ToShortDateString(),
                ValidTo = dto.ValidTo.ToShortDateString(),
                SellDate = dto.SellDate.ToShortDateString(),
                SellId = dto.SellId.ToString(),
                Notes = dto.Notes,
                XXX = dto.XXX
            };

            var qq = new List<string>();

            if (dto.BuyAndHoldTransactionTransactionsDto != null)
            {

                foreach (var ww in dto.BuyAndHoldTransactionTransactionsDto)
                {
                    qq.Add(ww.AmountInvested.ToString());
                }
                viewModel.qq = qq;
            }
            return viewModel;
        }
Пример #2
0
 public bool UpdateBuyAndHoldTransaction(BuyAndHoldRawTransactionDto dto)
 {
     var db = new InvestContext();
     //var model = db.BuyAndHoldTransactions.FirstOrDefault(p => p.Id == dto.Id);
     //model.TransactionDate = dto.TransactionDate;
     //model.BuyAndHoldTransactionId_In = dto.BuyAndHoldTransactionId_In;
     //model.TickerSymbol_In = dto.TickerSymbol_In;
     //model.SecurityId_In = dto.SecurityId_In;
     //model.Type_In = dto.Type_In;
     //model.AmountInvested_In = dto.AmountInvested_In;
     //model.NumberShares_In = dto.NumberShares_In;
     //model.BuyPrice_In = dto.BuyPrice_In;
     //model.BuyAndHoldTransactionId_Out = dto.BuyAndHoldTransactionId_Out;
     //model.TickerSymbol_Out = dto.TickerSymbol_Out;
     //model.SecurityId_Out = dto.SecurityId_Out;
     //model.Type_Out = dto.Type_Out;
     //model.AmountInvested_Out = dto.AmountInvested_Out;
     //model.NumberShares_Out = dto.NumberShares_Out;
     //model.BuyPrice_Out = dto.BuyPrice_Out;
     //model.TransactionApplied = dto.TransactionApplied;
     //model.ExchangeRate = dto.ExchangeRate;
     //model.Notes = dto.Notes;
     //model.Url1 = dto.Url1;
     //model.Url2 = dto.Url2;
     //model.Url3 = dto.Url3;
     //db.SaveChanges();
     return true;
 }
Пример #3
0
        public BuyAndHoldRawTransaction UpdateBuyAndHoldRawTransaction(BuyAndHoldRawTransactionDto dto)
        {
            var db = new InvestContext();
            var model = db.BuyAndHoldRawTransactions.FirstOrDefault(p => p.Id == dto.Id);

            model.Xref = dto.Xref;
            model.OriginalRawTransactionId = dto.OriginalRawTransactionId;
            model.TransactionDate = dto.TransactionDate.Value;
            model.SecurityId = dto.SecurityId.Value;
            model.TickerSymbol = dto.TickerSymbol;
            model.OriginalSecurityId = dto.OriginalSecurityId.HasValue ? (int?)dto.OriginalSecurityId.Value : null;
            model.OriginalTickerSymbol = dto.OriginalTickerSymbol;
            model.Company = dto.Company;
            model.Description = dto.Description;
            model.Quantity = dto.Quantity;
            model.Price = dto.Price;
            model.Amount = dto.Amount;
            model.Fees = dto.Fees;
            model.DebitCredit = dto.DebitCredit;
            model.SuspectedType = dto.SuspectedType;
            model.Period = dto.Period;
            model.TransactionType = dto.TransactionType;
            model.TransactionTypeId = dto.TransactionTypeId;
            model.TransactionApplied = dto.TransactionApplied;
            model.DividendAmount = dto.DividendAmount;
            model.AmountInvested = dto.AmountInvested;
            model.NumberShares = dto.NumberShares;
            model.BuyPrice = dto.BuyPrice;
            model.Split = dto.Split;
            model.ValidFrom = dto.ValidFrom;
            model.ValidTo = dto.ValidTo;
            model.SellDate = dto.SellDate;
            model.SellId = dto.SellId;
            model.Notes = dto.Notes;
            model.XXX = dto.XXX;

            db.SaveChanges();
            return model;
        }
Пример #4
0
 public BuyAndHoldRawTransactionDto UpdateBuyAndHoldRawTransaction(BuyAndHoldRawTransactionDto dto)
 {
     return _buyAndHoldManager.UpdateBuyAndHoldRawTransaction(dto);
 }
Пример #5
0
        public BuyAndHoldRawTransactionDto UpdateBuyAndHoldRawTransaction(BuyAndHoldRawTransactionDto dto)
        {
            if (dto.SecurityId.HasValue)
            {
                dto.TickerSymbol = _securityManager.GetById(dto.SecurityId.Value).TickerSymbol;

                //TODO look up Ticker symbol by date (assuming has changerd tickersymbol
                //dto.OriginalTickerSymbol = _securityManager.GetSecurityByIdByDate(dto.SecurityId.Value).TickerSymbol;
            }
            dto.TransactionType = GetRawTransactionType(dto.TransactionTypeId).Name;

            //if (dto.OriginalSecurityId.HasValue)
            //{
            //    if (dto.SecurityId == dto.OriginalSecurityId)
            //    {
            //        dto.OriginalSecurityId = null;
            //        dto.OriginalTickerSymbol = null;
            //    }
            //    else
            //    {
            //        dto.OriginalTickerSymbol = _securityManager.GetSecurityById(dto.OriginalSecurityId.Value).TickerSymbol;
            //    }
            //}

            dto.TransactionType = GetRawTransactionType(dto.TransactionTypeId).Name;

            var model = _buyAndHoldDal.UpdateBuyAndHoldRawTransaction(dto);
            return _buyAndHoldRawTransactionMapper.MapModelToDto(model);
        }
Пример #6
0
        private BuyAndHoldSplitTransactionViewModel MapDtoToBuyAndHoldSplitTransactionViewModel(BuyAndHoldRawTransactionDto buyAndHoldTransactionDto)
        {
            return new BuyAndHoldSplitTransactionViewModel
            {
                Amount = buyAndHoldTransactionDto.Amount,
                AmountInvested = buyAndHoldTransactionDto.AmountInvested.ToString(),
                BuyPrice = buyAndHoldTransactionDto.BuyPrice.ToString(),
                Company = buyAndHoldTransactionDto.Company,
                Credit = buyAndHoldTransactionDto.DebitCredit,
                Id = buyAndHoldTransactionDto.Id,
                Notes = buyAndHoldTransactionDto.Notes,
                NumberShares = buyAndHoldTransactionDto.NumberShares.ToString(),

                Price = buyAndHoldTransactionDto.Price,
                Quantity = buyAndHoldTransactionDto.Quantity,
                TickerSymbol = buyAndHoldTransactionDto.TickerSymbol,
                SuspectedType = buyAndHoldTransactionDto.SuspectedType,
                Date = buyAndHoldTransactionDto.TransactionDate.Value,
                Type = buyAndHoldTransactionDto.TransactionType
            };
        }
Пример #7
0
 private BuyAndHoldRawTransactionViewModel BuildBuyAndHoldRawTransactionViewModel(BuyAndHoldRawTransactionDto dto)
 {
     var viewModel = _buyAndHoldRawTransactionMapper.MapDtoToViewModel(dto);
     viewModel.TransactionTypes = new SelectList(_buyAndHoldService.GetRawTransactionTypes(), "Id", "Name", viewModel.TransactionTypeId);
     var securities = _securityService.GetSecurities();
     viewModel.Securities = new SelectList(securities, "Id", "TickerSymbol", viewModel.SecurityId);
     //viewModel.Securities2 = new SelectList(securities, "Id", "TickerSymbol", viewModel.OriginalSecurityId);
     return viewModel;
 }