Пример #1
0
 public BhSpinOffItemDto MapToDto(BhSpinOffItem model)
 {
     return new BhSpinOffItemDto
     {
         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,
     };
 }
Пример #2
0
        //        public BhSpinOffItem Create(BhSpinOffDto dto)
        public BhSpinOff Create(BhSpinOffDto dto)
        {
            //      var model = new BhSpinOffItem
            var model = new BhSpinOff
            {
                Id = dto.Id,
                TransactionDate = dto.TransactionDate,
                Notes = dto.Notes,
                TransactionApplied = dto.TransactionApplied,
            };

            var sourceModel = new BhSpinOffSource
            {
                Id = dto.SourceId,
                CostBasisSplit = dto.CostBasisSplit,
                SecurityId = dto.SecurityId,
                TickerSymbol = dto.TickerSymbol,
                Shares = dto.Shares,
                TransactionApplied = dto.SourceTransactionApplied
            };

            model.BhSpinOffSources.Add(sourceModel);

            foreach (var linkDto in dto.SpinOffLinks)
            {
                var linkModel = new BhSpinOffLink
                {
                    Url = linkDto.Url
                };
                model.BhSpinOffLinks.Add(linkModel);
            }

            foreach (var itemDto in dto.SpinOffItems)
            {
                var itemModel = new BhSpinOffItem
                {
                    BhTransactionDate = itemDto.BhTransactionDate,
                    BhTransactionId = itemDto.BhTransactionId,
                    TickerSymbol = itemDto.TickerSymbol,
                    SecurityId = itemDto.SecurityId,
                    Shares = itemDto.Shares,
                    Ratio = itemDto.Ratio,
                    CostBasisSplit = itemDto.CostBasisSplit,
                    TransactionApplied = itemDto.TransactionApplied,
                };

                model.BhSpinOffItems.Add(itemModel);
            }

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

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

            catch (Exception ex)
            {
                var w = ex.Message;
            }

            return model;
        }
Пример #3
0
 private BhSpinOffItem MapDtoToModel(BhSpinOffItemDto dto, BhSpinOffItem 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;
 }