예제 #1
0
        public async Task <List <Responses.Chart> > GetCharts(Period period = Period.ONE_MINUTE, List <string> currencyIds = null, List <string> userIds = null, List <string> indicatorIds = null)
        {
            // Get all currencies
            var currencies = await _mainDbContext.Currencies.Where(CurrencyExpression.Filter(currencyIds)).ToListAsync();

            // Get all indicators
            var indicators = await _mainDbContext.Indicators.Where(IndicatorExpression.Filter(indicatorIds)).ToListAsync();

            // Get all lines
            var lines = await _mainDbContext.Lines.Where(LineExpression.Filter(period, currencyIds, userIds, indicatorIds)).ToListAsync();

            // Build charts
            var charts = ChartBuilder.BuildCharts(currencies, indicators, lines);

            // Response
            var response = _mapper.Map <List <Responses.Chart> >(charts);

            // Return
            return(response);
        }
예제 #2
0
        public async Task <List <Responses.Indicator> > GetUserIndicators(string userId)
        {
            // Get user
            var user = await _mainDbContext.Users.FindAsync(userId);

            // Check if it exists
            if (user == null)
            {
                throw new NotFoundException(UserMessage.UserNotFound);
            }

            // Get all indicators
            var indicators = await _mainDbContext.Indicators
                             .Include(x => x.Dependencies)
                             .ThenInclude(x => x.Dependency)
                             .Where(IndicatorExpression.Filter(null, userId)).ToListAsync();

            // Response
            var response = _mapper.Map <List <Responses.Indicator> >(indicators);

            // Return
            return(response);
        }