public async Task <ActionResult> GetTopRobotCompaniesByRentsCountAsync(int?count) { var filterParams = new RobotPopularityFilterParamsDto { Type = RobotPopularity.ByRentCount, CountToTake = count ?? 5 }; var companies = await _robotCompanyService.GetTopNPopularCompaniesAsync(filterParams); return(Json(JsonResultData.Success(companies.Where(t => t.CountOfRents > 0).Select(t => new PieChartModel { Name = t.Name, Value = t.CountOfRents })))); }
public async Task <ActionResult> GetTopRobotCompaniesByRobotAndRentsCountAsync(int?count) { var filterParams = new RobotPopularityFilterParamsDto { Type = RobotPopularity.ByRobotAndRentCount, CountToTake = count ?? 5 }; var companies = await _robotCompanyService.GetTopNPopularCompaniesAsync(filterParams); var response = new BarChartModel { Titles = companies.Select(t => t.Name), RobotRentsCount = companies.Select(t => t.CountOfRents), RobotsCount = companies.Select(t => t.CountOfRobots) }; return(Json(JsonResultData.Success(response))); }
public async Task <IEnumerable <GetRobotModelPopularityDto> > GetTopNPopularModelsAsync(RobotPopularityFilterParamsDto filterParams, CancellationToken ct = default) { var robotModelFilterParams = _mapper.Map <RobotPopularityFilterParams>(filterParams); var items = await _unitOfWork.RobotModelRepository.GetTopNPopularModelsAsync(robotModelFilterParams, ct); return(_mapper.Map <IEnumerable <GetRobotModelPopularityDto> >(items)); }