Example #1
0
        public HistoricalCompanyName UpdateHistoricalCompanyName(HistoricalCompanyNameDto dto)
        {
            var model = _context.HistoricalCompanyNames.FirstOrDefault(p => p.Id == dto.Id);

            model.SecurityId = dto.SecurityId;
            model.CompanyName = dto.CompanyName;

            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;
        }
        public HistoricalCompanyNameViewModel MapDtoToViewModel(HistoricalCompanyNameDto dto)
        {
            var model =  new HistoricalCompanyNameViewModel
            {
                Id = dto.Id,
                SecurityId = dto.SecurityId,
                CompanyName = dto.CompanyName,
                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;
        }
Example #3
0
        public HistoricalCompanyName Update(HistoricalCompanyNameDto dto)
        {
            HistoricalCompanyName model;
            //using (var context = new InvestContext())
            var context = new InvestContext();
            //{
            model = context.HistoricalCompanyNames.FirstOrDefault(p => p.Id == dto.Id);

            model.ValidFrom = dto.ValidFrom;
            model.CompanyName = dto.CompanyName;
            //model. = dto.Notes;
            //model.TickerSymbol = dto.TickerSymbol;
            context.SaveChanges();
            //}
            return model;
        }
        public HistoricalCompanyNameDto MapViewModelToDto(HistoricalCompanyNameViewModel ViewModel)
        {
            var dto = new HistoricalCompanyNameDto
            {
                Id = ViewModel.Id,
                SecurityId = ViewModel.SecurityId,
                CompanyName = ViewModel.CompanyName,
                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 HistoricalCompanyNameDto Update(HistoricalCompanyNameDto dto)
 {
     throw new NotImplementedException();
 }
Example #6
0
 public HistoricalCompanyNameDto UpdateHistoricalCompanyName(HistoricalCompanyNameDto dto)
 {
     return _securityManager.UpdateHistoricalCompanyName(dto);
 }
Example #7
0
 public HistoricalCompanyNameDto UpdateHistoricalCompanyName(HistoricalCompanyNameDto dto)
 {
     var security = _securityDal.UpdateHistoricalCompanyName(dto);
     return _historicalCompanyNameMapper.MapModelToDto(security);
 }