public async Task <PlanSummary> GetPlanSummary(int userId, int planId) { var dates = await GetPlanDates(userId, planId); var startDate = dates.StartDate; var endDate = dates.EndDate; var planSummary = new PlanSummary() { Amount = await GetPlanAmount(userId, planId), AverageMoneyLeftPerDay = await GetAverageMoneyLeftPerDayForPlan(userId, planId, startDate, endDate), AverageMoneySpentPerDay = await GetAverageMoneySpentPerDayForPlan(userId, startDate, endDate), MoneyLeft = await GetMoneyLeftForPlan(userId, planId, startDate, endDate), MoneyLeftPercentage = await GetMoneyLeftForPlanPercentage(userId, planId, startDate, endDate), MoneySpentOnCategories = await GetMoneySpentOnCategories(userId, startDate, endDate), MoneySpentPercentage = await GetMoneySpentForPlanPercentage(userId, planId, startDate, endDate), MostExpensiveProduct = await GetMostExpensiveProduct(userId, startDate, endDate), MostPopularCategory = await GetMostPopularCategoryForPlan(userId, startDate, endDate), MostPopularProduct = await GetMostPopularProductForPlan(userId, startDate, endDate), ProductsBoughtAmount = await GetProductsAmountForPlan(userId, startDate, endDate), MostExpensiveProductName = await _dbHelper.GetProductName(await GetMostExpensiveProduct(userId, startDate, endDate)), MostPopularCategoryName = await _dbHelper.GetCategoryName(await GetMostPopularCategoryForPlan(userId, startDate, endDate)), MostPopularProductName = await _dbHelper.GetProductName(await GetMostPopularProductForPlan(userId, startDate, endDate)), }; return(planSummary); }
public async Task <IActionResult> GetSummary(string id) { PlanSummary summary = await _planService.GetSummaryAsync(id); return(Ok(summary)); }