public Statistic PassTest(PassTestModel passTest) { double percentage = CountPercentageOfRightAnswers(passTest.UserAnswers); TimeSpan time = DateTime.Now - passTest.BeginDate; Statistic statistic = new Statistic { TestId = passTest.TestId, UserId = passTest.UserId, Date = DateTime.Now, Time = new TimeSpan(time.Hours, time.Minutes, time.Seconds), Percentage = percentage, IsPassed = (percentage >= passTest.MinPercentage) }; if (statisticRepository.IsUserPassedTest(passTest.UserId, passTest.TestId)) { statisticRepository.Update(statistic); } else { statisticRepository.Create(statistic); } Statistic st = statisticRepository.GetStatistic(passTest.UserId, passTest.TestId); return(st); }
private TImageStatistic CreateInitialStatistic() { var newStat = new TImageStatistic { TotalNumberOfImages = _imageRepository.AmounthOfItems(), NumberOfOptimizedImages = _imageRepository.AmounthOfOptimizedItems(), TotalSavedBytes = 0 }; _statisticRepository.Create(newStat); return(newStat); }