public async Task <List <Responses.Indicator> > GetAllIndicators(string userId, IndicatorType indicatorType) { // Get user var user = await _userRepository.GetSingle(userId); // Check if it exists if (user == null) { throw new NotFoundException(UserMessage.UserNotFound); } // Get all indicators var indicators = await _indicatorRepository.GetAll(IndicatorExpression.IndicatorFilter(indicatorType, null, userId)); // Get all indicator dependencies var indicatorDependencies = await _indicatorDependencyRepository.GetAll(); // Build indicator dependencies IndicatorBuilder.BuildDependencies(indicators, indicatorDependencies); // Response var response = _mapper.Map <List <Responses.Indicator> >(indicators); // Return return(response); }
public async Task <List <Responses.LineChart> > GetAllLineCharts(string currencyId = null, IndicatorType?indicatorType = null, string indicatorId = null, string userId = null) { // Get all currencies var currencies = await _currencyRepository.GetAll(CurrencyExpression.CurrencyFilter(currencyId)); // Get all indicators var indicators = await _indicatorRepository.GetAll(IndicatorExpression.IndicatorFilter(indicatorType, indicatorId, userId)); // Get all lines var lines = await _lineRepository.GetAll(LineExpression.LineFilter(currencyId, indicatorType, indicatorId, userId)); // Build var lineCharts = LineChartBuilder.BuildLineCharts(currencies, indicators, lines); // Response var response = _mapper.Map <List <Responses.LineChart> >(lineCharts); // Return return(response); }
public async Task <List <Responses.Chart> > GetAllCharts(string currencyId = null, IndicatorType?indicatorType = null, string indicatorId = null, string userId = null) { // Get all currencies var currencies = await _mainDbContext.Currencies.Where(CurrencyExpression.CurrencyFilter(currencyId)).ToListAsync(); // Get all indicators var indicators = await _mainDbContext.Indicators.Where(IndicatorExpression.IndicatorFilter(indicatorType, indicatorId, userId)).ToListAsync(); // Get all lines var lines = await _mainDbContext.Lines.Where(LineExpression.LineFilter(currencyId, indicatorType, indicatorId, userId)).ToListAsync(); // Build var charts = ChartBuilder.BuildCharts(currencies, indicators, lines); // Response var response = _mapper.Map <List <Responses.Chart> >(charts); // Return return(response); }
public async Task <List <Responses.Indicator> > GetAllIndicators(string userId, IndicatorType indicatorType) { // 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) .Where(IndicatorExpression.IndicatorFilter(indicatorType, null, userId)).ToListAsync(); // Response var response = _mapper.Map <List <Responses.Indicator> >(indicators); // Return return(response); }