Esempio n. 1
0
        //BhSpinOff
        public BhSpinOffDto MapToDto(BhSpinOff model)
        {
            var dto = new BhSpinOffDto
            {
                Id = model.Id,
                TransactionDate = model.TransactionDate,
                Notes = model.Notes,
                TransactionApplied = model.TransactionApplied,
                SpinOffItems = MapToDto(model.BhSpinOffItems),
                SpinOffLinks = MapToDto(model.BhSpinOffLinks),
                BuyAndHoldTransactions = _buyAndHoldTransactionDomainMap.MapToDto(model.BuyAndHoldTransactions),
            };

            if (model.BhSpinOffSources != null && model.BhSpinOffSources.Count > 0)
            {
                dto.SourceId = model.BhSpinOffSources.First().Id;
                //dto.BhTransactionId = model.BhSpinOffSources.First().BhTransactionId;
                //dto.BhTransactionDate = model.BhSpinOffSources.First().BhTransactionDate;

                dto.SecurityId = model.BhSpinOffSources.First().SecurityId;
                dto.TickerSymbol = model.BhSpinOffSources.First().TickerSymbol;
                dto.Shares = model.BhSpinOffSources.First().Shares;
                dto.CostBasisSplit = model.BhSpinOffSources.First().CostBasisSplit;
                dto.SourceTransactionApplied = model.BhSpinOffSources.First().TransactionApplied;
            }
            return dto;
        }
Esempio n. 2
0
 public BhSpinOffDto CreateSpinOff(BhSpinOffDto dto)
 {
     return _bhManager.CreateSpinOff(dto);
 }
Esempio n. 3
0
 //public IEnumerable<BhSpinOffSourceDto> GetSpinOffSources()
 //{
 //    return _bhManager.GetSpinOffSources();
 //}
 public BhSpinOffDto UpdateSpinOff(BhSpinOffDto dto)
 {
     return _bhManager.UpdateSpinOff(dto);
 }
Esempio n. 4
0
 public BhSpinOffDto CreateSpinOff(BhSpinOffDto dto)
 {
     var model = _bhSpinOffDal.Create(dto);
     return _bhSpinOffDomainMap.MapToDto(model);
 }
Esempio n. 5
0
        //BhSpinOff
        public BhSpinOffViewModel MapToViewModel(BhSpinOffDto dto)
        {
            return new BhSpinOffViewModel
            {
                Id = dto.Id,
                TransactionDate = dto.TransactionDate,
                //Ratio = model.Ratio,
                Notes = dto.Notes,
                TransactionApplied = dto.TransactionApplied,
                SpinOffItems = MapToViewModel(dto.SpinOffItems),
                SpinOffLinks = MapToViewModel(dto.SpinOffLinks),
                Transactions = _buyAndHoldTransactionDtoMap.MapToViewModel(dto.BuyAndHoldTransactions),
                SourceId = dto.SourceId,
                //BhTransactionId = dto.BhTransactionId,
                //BhTransactionDate = dto.BhTransactionDate,

                SecurityId = dto.SecurityId,
            TickerSymbol = dto.TickerSymbol,
            Shares = dto.Shares,
            CostBasisSplit = dto.CostBasisSplit,
            SourceTransactionApplied = dto.SourceTransactionApplied,

            };
        }
Esempio n. 6
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;
        }
Esempio n. 7
0
 private BhSpinOffSource MapDtoToModel(BhSpinOffDto dto, BhSpinOffSource model)
 {
     model.Id = dto.SourceId;
     ////model.BhTransactionId = dto.BhTransactionId;
     ////model.BhTransactionDate = dto.BhTransactionDate;
     model.SecurityId = dto.SecurityId;
     model.TickerSymbol = dto.TickerSymbol;
     model.Shares = dto.Shares;
     model.CostBasisSplit = dto.CostBasisSplit;
     ////Property(t => t.CostBasisSplit).HasColumnName("CostBasisSplit");
     model.TransactionApplied = dto.SourceTransactionApplied;
     return model;
 }
Esempio n. 8
0
        public BhSpinOff Update(BhSpinOffDto dto)
        {
            //var model = _context.BhSpinOffItems.FirstOrDefault(p => p.Id == dto.Id);
            var model = _context.BhSpinOffs.FirstOrDefault(p => p.Id == dto.Id);
            model.TransactionDate = dto.TransactionDate;
            model.Notes = dto.Notes;
            model.TransactionApplied = dto.TransactionApplied;

            if (dto.SourceId > 0)
            {
                var sourcemodel = _context.BhSpinOffSources.FirstOrDefault(p => p.Id == dto.SourceId);
                MapDtoToModel(dto, sourcemodel);
            }
            else
            {
                model.BhSpinOffSources.Add(MapDtoToModel(dto, new BhSpinOffSource()));
            }

            var sourceModel = new BhSpinOffSource
            {
                Id = dto.SourceId,
                ////BhTransactionId = dto.BhTransactionId,
                ////BhTransactionDate = dto.BhTransactionDate,

                SecurityId = dto.SecurityId,
                TickerSymbol = dto.TickerSymbol,
                Shares = dto.Shares,
                TransactionApplied = dto.SourceTransactionApplied
            };

            model.BhSpinOffSources.Add(sourceModel);

            foreach (var linkDto in dto.SpinOffLinks)
            {
                if (linkDto.Id > 0)
                {
                    var linkModel = _context.BhSpinOffLinks.FirstOrDefault(p => p.Id == linkDto.Id);
                    MapDtoToModel(linkDto, linkModel);
                }
                else
                {
                    model.BhSpinOffLinks.Add(MapDtoToModel(linkDto, new BhSpinOffLink()));
                }
            }

            foreach (var itemDto in dto.SpinOffItems)
            {
                if (itemDto.Id > 0)
                {
                    var itemModel = _context.BhSpinOffItems.FirstOrDefault(p => p.Id == itemDto.Id);
                    MapDtoToModel(itemDto, itemModel);
                }
                else
                {
                    model.BhSpinOffItems.Add(MapDtoToModel(itemDto, new BhSpinOffItem()));
                }
            }

            _context.BhSpinOffs.Add(model);
            _context.SaveChanges();

            return model;
        }