Exemplo n.º 1
0
        public IncrementViewsHandlerResponse Handle(IncrementViewsHandlerRequest request)
        {
            var forToday = _viewStatisticRepository.GetByDate(DateTime.Today);

            if (forToday == null)
            {
                forToday = new ViewStatistic
                {
                    Date  = DateTime.Today,
                    Count = 0
                };
                _viewStatisticRepository.Add(forToday);
            }

            forToday.Increment();
            _dbContext.SaveChanges();
            return(new IncrementViewsHandlerResponse());
        }
Exemplo n.º 2
0
 public void Add(ViewStatistic stat)
 {
     _dbContext.Add(stat);
 }