Esempio n. 1
0
 public BhMergerItemDto MapToDto(BhMergerItem model)
 {
     return new BhMergerItemDto
     {
         Id = model.Id,
         BhTransactionDate = model.BhTransactionDate,
         BhTransactionId = model.BhTransactionId,
         TickerSymbol = model.TickerSymbol,
         SecurityId = model.SecurityId,
         Shares = model.Shares,
         Ratio = model.Ratio,
         CashPerShare = model.CashPerShare,
         CashRecieved = model.CashRecieved,
         CostBasisSplit = model.CostBasisSplit,
         TransactionApplied = model.TransactionApplied,
     };
 }
Esempio n. 2
0
        public BhMerger Create(BhMergerDto dto)
        {
            var model = new BhMerger
            {
                Id = dto.Id,
                TransactionDate = dto.TransactionDate,
                Notes = dto.Notes,
                TransactionApplied = dto.TransactionApplied,
            };

            var sourceModel = new BhMergerSource
            {
                Id = dto.SourceId,
                BhTransactionId = dto.BhTransactionId,
                BhTransactionDate = dto.BhTransactionDate,
                SecurityId = dto.SecurityId,
                TickerSymbol = dto.TickerSymbol,
                Shares = dto.Shares,
                TransactionApplied = dto.SourceTransactionApplied
            };

            model.BhMergerSources.Add(sourceModel);

            foreach (var linkDto in dto.MergerLinks)
            {
                var linkModel = new BhMergerLink
                {
                    Url = linkDto.Url
                };
                model.BhMergerLinks.Add(linkModel);
            }

            foreach (var itemDto in dto.MergerItems)
            {
                var itemModel = new BhMergerItem
                {
                    BhTransactionDate = itemDto.BhTransactionDate,
                    BhTransactionId = itemDto.BhTransactionId,
                    TickerSymbol = itemDto.TickerSymbol,
                    SecurityId = itemDto.SecurityId,
                    Shares = itemDto.Shares,
                    Ratio = itemDto.Ratio,
                    CashPerShare = itemDto.CashPerShare,
                    CashRecieved = itemDto.CashRecieved,
                    CostBasisSplit = itemDto.CostBasisSplit,
                    TransactionApplied = itemDto.TransactionApplied,
                };

                model.BhMergerItems.Add(itemModel);
            }

            _context.BhMergers.Add(model);
            try
            {
                _context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                _context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                var w = ex.Message;
            }

            return model;
        }
Esempio n. 3
0
 private BhMergerItem MapDtoToModel(BhMergerItemDto dto, BhMergerItem model)
 {
     model.BhTransactionDate = dto.BhTransactionDate;
     model.BhTransactionId = dto.BhTransactionId;
     model.TickerSymbol = dto.TickerSymbol;
     model.SecurityId = dto.SecurityId;
     model.Shares = dto.Shares;
     model.Ratio = dto.Ratio;
     model.CashPerShare = dto.CashPerShare;
     model.CashRecieved = dto.CashRecieved;
     model.CostBasisSplit = dto.CostBasisSplit;
     model.TransactionApplied = dto.TransactionApplied;
     return model;
 }