Example #1
0
 /// <summary>
 /// Create Statistic
 /// </summary>
 /// <param name="entity">TImageStatistic</param>
 public void Create(TImageStatistic entity)
 {
     using (IScope scope = _scopeProvider.CreateScope())
     {
         var database = scope.Database;
         database.Insert(entity);
         scope.Complete();
     }
 }
Example #2
0
 /// <summary>
 /// Update Statistic
 /// </summary>
 /// <param name="entity">TImageStatistic</param>
 public void Update(TImageStatistic entity)
 {
     using (IScope scope = _scopeProvider.CreateScope())
     {
         var database = scope.Database;
         var query    = new Sql("UPDATE TinifierImagesStatistic SET NumberOfOptimizedImages = @0, TotalNumberOfImages = @1, TotalSavedBytes = @2", entity.NumberOfOptimizedImages, entity.TotalNumberOfImages, entity.TotalSavedBytes);
         database.Execute(query);
         scope.Complete();
     }
 }
        private TImageStatistic CreateInitialStatistic()
        {
            var newStat = new TImageStatistic
            {
                TotalNumberOfImages     = _imageRepository.AmounthOfItems(),
                NumberOfOptimizedImages = _imageRepository.AmounthOfOptimizedItems(),
                TotalSavedBytes         = 0
            };

            _statisticRepository.Create(newStat);
            return(newStat);
        }
        public void CreateStatistic()
        {
            var statistic = _statisticRepository.GetStatistic();

            if (statistic == null)
            {
                var newStat = new TImageStatistic
                {
                    TotalNumberOfImages     = _imageRepository.AmounthOfItems(),
                    NumberOfOptimizedImages = _imageRepository.AmounthOfOptimizedItems()
                };

                _statisticRepository.Create(newStat);
            }
        }