コード例 #1
0
        public async Task <ShopSummary> GetShopSummary(int userId, int shopId, string startDate, string endDate)
        {
            var start       = DateTime.Parse(startDate);
            var end         = DateTime.Parse(endDate);
            var visitAmount = await GetVisitAmount(userId, shopId, start, end);

            if (visitAmount <= 0)
            {
                return(new ShopSummary()
                {
                    VisitAmount = 0
                });
            }
            var mostPopularCategory = await GetMostPopularCategory(userId, shopId, start, end);

            var lestPopularCategory = await GetLeastPopularCategory(userId, shopId, start, end);

            var shopSummary = new ShopSummary()
            {
                AverageCategoryAmountForReceipt = await GetAverageAmountOfCategories(userId, shopId, start, end),
                AverageMoneySpentPerDay         = await GetAverageMoneySpentInShopPerDay(userId, shopId, start, end),
                AverageMoneySpentOnEachCategory = await GetAverageMoneySpentOnCategories(userId, shopId, start, end),
                AverageProductAmountBought      = await GetAverageProductsAmountBoughtInShop(userId, shopId, start, end),
                MaxCategoryAmountForReceipt     = GetMaxAmountOfAllCategories(userId, shopId, start, end),
                MaxProductAmountBought          = GetMaxProductsAmountBoughtInShop(userId, shopId, start, end),
                MinCategoryAmountForReceipt     = GetMinAmountOfAllCategories(userId, shopId, start, end),
                MinProductAmountBought          = GetMinProductsAmountBoughtInShop(userId, shopId, start, end),
                MoneyAverageSpentAmount         = await GetAvarageMoneySpentInShop(userId, shopId, start, end),
                MoneyMaxSpentAmount             = GetMaxMoneySpentInShop(userId, shopId, start, end),
                MoneyMinSpentAmount             = GetMinMoneySpentInShop(userId, shopId, start, end),
                MoneySpentAmount            = await GetTotalSpentAmount(userId, shopId, start, end),
                ProductsBoughtAverageAmount = await GetAverageProductsBoughtInShop(userId, shopId, start, end),
                ProductsBoughtMaxAmount     = GetMaxProductsBoughtInShop(userId, shopId, start, end),
                ProductsBoughtMinAmount     = GetMinProductsBoughtInShop(userId, shopId, start, end),
                ProductsBoughtTotalAmount   = await GetTotalProductsBoughtInShop(userId, shopId, start, end),
                TotalCategoriesAmount       = await GetAmountOfAllCategories(userId, shopId, start, end),
                TotalProductAmountBought    = await GetTotalProductsAmountBoughtInShop(userId, shopId, start, end),
                VisitAmount              = visitAmount,
                MostPopularCategory      = mostPopularCategory,
                LeastPopularCategory     = lestPopularCategory,
                MostPopularCategoryName  = await _dbHelper.GetCategoryName(mostPopularCategory),
                LeastPopularCategoryName = await _dbHelper.GetCategoryName(lestPopularCategory)
            };

            return(shopSummary);
        }
コード例 #2
0
        public async Task <ShopSummary> GetShopList()
        {
            ShopSummary shopSummary = new ShopSummary();

            shopSummary.Shops.AddRange(await _unitOfWork.StoresRepository.
                                       GetEntityAsNoTracking(entity => entity.Ativo).
                                       Select(entity => new Shop
            {
                Id       = entity.ID,
                ShopDesc = entity.Descricao,
                ShopName = entity.Descricao
            }).
                                       OrderBy(entity => entity.ShopDesc).
                                       ToListAsync());

            return(shopSummary);
        }
コード例 #3
0
 public IActionResult Details(ShopSummary model)
 {
     return(this.View(model));
 }