public StockProprtiesViewModel(IEventAggregator eventAggregator, IStockPropertiesService stockPropertiesService)
 {
     model = new StockPropertiesModel();
     this.eventAggregator        = eventAggregator;
     this.stockPropertiesService = stockPropertiesService;
     SubscribeEvents();
 }
        public async Task <List <PropertiesModel> > GetStockData()
        {
            try
            {
                StockPropertiesModel blobData = await _externalApi.GetStockData();

                List <PropertiesModel> properties = new List <PropertiesModel>();
                foreach (var property in blobData.Properties)
                {
                    if (property.Financial != null && property.Physical != null)
                    {
                        properties.Add(CastStockData(property));
                    }
                    else
                    {
                        _logger.Warn($"The element with Id {property.Id} has null values on Financial and Physical properties");
                    }
                }
                return(properties);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public async Task <List <PropertiesModel> > GetStockData()
        {
            try
            {
                //Calling an external layer to get the API info
                StockPropertiesModel blobData = await _externalApi.GetStockData();

                List <PropertiesModel> properties = new List <PropertiesModel>();
                //Looping into the data
                foreach (var property in blobData.Properties)
                {
                    //Validating if the Financial and Physical properties are correctly populated
                    if (property.Financial != null && property.Physical != null)
                    {
                        //Calling the metod to cast the properties into the object that we'll return
                        properties.Add(CastStockData(property));
                    }
                    else
                    {
                        //Logging the validation as a warning
                        _logger.Warn($"The element with Id {property.Id} has null values on Financial and Physical properties");
                    }
                }
                return(properties);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }