public HistoricalTickerSymbol Update(HistoricalTickerSymbolDto dto)
        {
            HistoricalTickerSymbol model;
            //using (var context = new InvestContext())
            var context = new InvestContext();
            //{
            model = context.HistoricalTickerSymbols.FirstOrDefault(p => p.Id == dto.Id);

            //model.Active = dto.Active;
            //model.CompanyName = dto.CompanyName;
            //model.Notes = dto.Notes;
            model.TickerSymbol = dto.TickerSymbol;
            context.SaveChanges();
            //}
            return model;
        }
        public HistoricalTickerSymbolViewModel MapDtoToViewModel(HistoricalTickerSymbolDto dto)
        {
            var model = new HistoricalTickerSymbolViewModel
            {
                Id = dto.Id,
                SecurityId = dto.SecurityId,
                TickerSymbol = dto.TickerSymbol,
                ValidFrom = dto.ValidFrom,
                ValidTo = dto.ValidTo,
            };

            model.ValidToString = dto.ValidTo.HasValue ? dto.ValidTo.Value.ToShortDateString() : string.Empty;
            model.ValidFromString = dto.ValidFrom.HasValue ? dto.ValidFrom.Value.ToShortDateString() : string.Empty;

            return model;
        }
        public HistoricalTickerSymbolDto MapViewModelToDto(HistoricalTickerSymbolViewModel ViewModel)
        {
            var dto = new HistoricalTickerSymbolDto
            {
                Id = ViewModel.Id,
                SecurityId = ViewModel.SecurityId,
                TickerSymbol = ViewModel.TickerSymbol,
                ValidFrom = ViewModel.ValidFrom,
                ValidTo = ViewModel.ValidTo,

            };

            if (!string.IsNullOrWhiteSpace(ViewModel.ValidToString))
            {
                dto.ValidTo = DateTime.Parse(ViewModel.ValidToString);
            }

            if (!string.IsNullOrWhiteSpace(ViewModel.ValidFromString))
            {
                dto.ValidFrom = DateTime.Parse(ViewModel.ValidFromString);
            }
            return dto;
        }
 public HistoricalTickerSymbolDto Update(HistoricalTickerSymbolDto dto)
 {
     var security = _historicalTickerSymbolDal.Update(dto);
     return _historicalTickerSymbolMapper.MapModelToDto(security);
 }
Esempio n. 5
0
        public HistoricalTickerSymbol UpdateHistoricalTickerSymbol(HistoricalTickerSymbolDto dto)
        {
            var model = _context.HistoricalTickerSymbols.FirstOrDefault(p => p.Id == dto.Id);

            model.SecurityId = dto.SecurityId;
            model.TickerSymbol = dto.TickerSymbol;

            if (dto.ValidFrom.HasValue)
            {
                model.ValidFrom = dto.ValidFrom.Value;
            }
            else
            {
                model.ValidFrom = null;
            }

            if (dto.ValidTo.HasValue)
            {
                model.ValidTo = dto.ValidTo.Value;
            }
            else
            {
                model.ValidTo = null;
            }

            _context.SaveChanges();

            return model;
        }
Esempio n. 6
0
 public HistoricalTickerSymbolDto UpdateHistoricalTickerSymbol(HistoricalTickerSymbolDto dto)
 {
     return _securityManager.UpdateHistoricalTickerSymbol(dto);
 }