Пример #1
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;
        }
Пример #2
0
 //BhMergerLink
 public BhMergerLinkDto MapToDto(BhMergerLink model)
 {
     return new BhMergerLinkDto
     {
         Id = model.Id,
         MergerId = model.MergerId,
         Url = model.Url
     };
 }
Пример #3
0
 private BhMergerLink MapDtoToModel(BhMergerLinkDto dto, BhMergerLink model)
 {
     model.Url = dto.Url;
     return model;
 }