Exemple #1
0
        public async Task IncrementViewsAmountAsync(Guid discountId)
        {
            var dateNow = DateTime.UtcNow.Date;

            Expression <Func <Statistics, bool> > expression = s => s.DiscountId == discountId &&
                                                               s.DateTime == dateNow;

            if (await _statisticsRepository.StatisticsExists(expression))
            {
                await _statisticsRepository.UpdateIncrementAsync(expression, d => d.ViewsAmount, 1);
            }
            else
            {
                await _statisticsRepository.CreateAsync(new Statistics
                {
                    DiscountId  = discountId,
                    DateTime    = dateNow,
                    ViewsAmount = 1
                });
            }
        }