public async Task <IEnumerable <FigiInstrument> > Handle(GetSecurityLevelInfoCommand request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var results = new FigiInstrument();
            //validate id
            var res = Validator.Validate(request);

            if (res.IsValid)
            {
                if (FigiExists(request.Ticker))
                {
                    return new List <FigiInstrument> {
                               DbContext.Figi.Where(x => x.Ticker == request.Ticker).FirstOrDefault()
                    }
                }
                ;

                string response = await MappingService.MapTickerToFigi(request.Ticker);

                if (response != null) //add response
                {
                    await AddFigiToDB(response);

                    results = DbContext.Figi.Where(x => x.Ticker == request.Ticker).FirstOrDefault();
                }
            }
            return(new List <FigiInstrument>()
            {
                results
            });
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <FigiInstrument> > > GetSecurityLevelInfo([FromRoute] GetSecurityLevelInfoCommand command, CancellationToken cancellationToken = default)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var res = await GetSecurityLevelInfoCommandHandler.Handle(command, cancellationToken);

            if (res != null)
            {
                return(Ok(res));
            }

            return(Ok("No records found"));
        }