Esempio n. 1
0
        public void Can_Generate_Review_Count_Array()
        {
            var note1 = new Note
            {
                User = user
            };

            var model1 = new StatsViewModel
            {
                Reviews = new List <Review>
                {
                    new Review
                    {
                        Date = DateTime.UtcNow.AddDays(0),
                        Note = note1
                    }
                }
            };

            int dayRange = 2;
            var reviews1 = model1.ReviewCount(dayRange);

            Assert.AreEqual(2, reviews1.Length);
            Assert.AreEqual(1, reviews1[dayRange - 1]); // day 0
        }
        public StatsViewModel GetStats()
        {
            var jokesContext = _context.Jokes.Include(joke => joke.Votes).ToList();
            var jokes        = AutoMapper.Mapper.Map <List <JokeViewModel> >(jokesContext);

            var bestJoke  = jokes.Aggregate((j1, j2) => j1.UpVotes > j2.UpVotes ? j1 : j2);
            var worstJoke = jokes.Aggregate((j1, j2) => j1.DownVotes > j2.DownVotes ? j1 : j2);

            var bestAuthor = jokes.Where(joke => joke.UpVotes > joke.DownVotes)
                             .GroupBy(j => j.Author)
                             .OrderByDescending(grp => grp.Count())
                             .FirstOrDefault()?.Key;

            var worstAuthor = jokes.Where(joke => joke.DownVotes > joke.UpVotes)
                              .GroupBy(j => j.Author)
                              .OrderByDescending(grp => grp.Count())
                              .FirstOrDefault()?.Key;

            StatsViewModel result = new StatsViewModel()
            {
                BestAuthor  = bestAuthor,
                BestJoke    = bestJoke,
                WorstAuthor = worstAuthor,
                WorstJoke   = worstJoke
            };

            return(result);
        }
Esempio n. 3
0
        public void ComputeStatsForAllTime(IReadOnlyCollection<Report> allReports, StatsViewModel vm)
        {
            var allCreated =    allReports.Count(report => report.Status == ReportStatus.Created);
            var allCompleted  = allReports.Count(report => report.Status == ReportStatus.Completed);
            var allProcessing = allReports.Count(report => report.Status == ReportStatus.Processing);
            var allFailed     = allReports.Count(report => report.Status == ReportStatus.Failure);
            var allSummary    = allReports.Count;

            vm.AllTime = new StatsViewModel.AllTimeStats
            {
                Numbers      = new StatsViewModel.Numbers
                {
                    ReportsCount      = allSummary,
                    ReportsCreated    = allCreated,
                    ReportsCompleted  = allCompleted,
                    ReportsProcessing = allProcessing,
                    ReportsFailed     = allFailed
                },
                Percentages  = new StatsViewModel.Percentages
                {
                    AverageReportsCompleted  = (double)allCompleted  / (allSummary) * 100.0,
                    AverageReportsProcessing = (double)allProcessing / (allSummary) * 100.0,
                    AverageReportsFailure    = (double)allFailed     / (allSummary) * 100.0
                }
            };
        }
Esempio n. 4
0
        public void StatsByCategoryPercentRoundValueToTwoDecimalPlaces2()
        {
            List <Customer> customers = new List <Customer>()
            {
                TestHelpers.GetSampleCustomer(),
                            TestHelpers.GetSampleCustomer(),
                            TestHelpers.GetSampleCustomer(),
            };

            customers[0].Category = Category.A;
            customers[1].Category = Category.B;
            customers[2].Category = Category.B;

            StatsViewModel viewModel = new StatsViewModel(customers);

            viewModel.SelectedStatsType = StatsType.Category;

            List <Tuple <string, decimal, decimal> > expectedList = new List <Tuple <string, decimal, decimal> >()
            {
                new Tuple <string, decimal, decimal>("A", 1, 33.33m),
                new Tuple <string, decimal, decimal>("B", 2, 66.67m),
            };

            CollectionAssert.AreEquivalent(expectedList, viewModel.StatsDataPercent);
        }
Esempio n. 5
0
        public IActionResult Stats()
        {
            var userId       = _userManager.GetUserId(User);
            var userProducts = _mainRepository.GetAllProductsOfUser(userId).ToList();

            int commentsGot = 0;

            foreach (var p in userProducts)
            {
                var productComments = _mainRepository.GetUserCommentsByProdID(p.ID).ToList();
                commentsGot += productComments.Count();
            }

            var commentsWritten = _mainRepository.GetUserCommentsByUserID(userId).Count();
            var totalAdded      = _mainRepository.GetAllProductsOfUser(userId).Count();
            var totalBought     = _mainRepository.GetBoughtProductsByUserId(userId).Count();
            var totalStars      = (from p in userProducts select p.GetTotalStarsCount(_mainRepository)).Sum(x => Convert.ToInt32(x));

            StatsViewModel model = new StatsViewModel
            {
                TotalCommentsWritten = commentsWritten,
                TotalCommentsGot     = commentsGot,
                TotalProductsAdded   = totalAdded,
                TotalProductsBought  = totalBought,
                TotalStarsAmount     = totalStars
            };

            return(View(model));
        }
Esempio n. 6
0
        public ActionResult Panel()
        {
            ViewBag.Message = "Aktualne pomiary";
            StatsViewModel SVM = new StatsViewModel(Startup.DeviceList.Devices.Find(x => x.name == UserManager.FindById(User.Identity.GetUserId()).DeviceName), UserManager.FindById(User.Identity.GetUserId()).KwhPrice);

            return(View(SVM));
        }
Esempio n. 7
0
        public IActionResult Index()
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var stats = this.statsService.GetUserStats <UserStatsViewModel>(userId);

            if (stats == null)
            {
                this.statsService.InitiateStats(userId);
                Thread.Sleep(100);
            }

            var userStats = this.statsService.GetUserStats <UserStatsViewModel>(userId);

            var model = new StatsViewModel
            {
                UserName   = this.User.Identity.Name,
                UserStats  = userStats,
                TotalUsers = this.userManager.Users.Count(),
                LastThirtyDaysRegisteredUsers = this.userManager.Users.Where(x => x.CreatedOn >= DateTime.Now.AddDays(-30)).Count(),
                TotalGames    = this.statsService.GetTotalGames(),
                MostGamesUser = this.statsService.GetMostGamesUser(),
                MostWinsUser  = this.statsService.GetMostWinsUser(),
            };

            return(this.View(model));
        }
Esempio n. 8
0
        public void StatsByLocationPercentRoundValueToTwoDecimalPlaces2()
        {
            List <Customer> customers = new List <Customer>()
            {
                TestHelpers.GetSampleCustomer(),
                            TestHelpers.GetSampleCustomer(),
                            TestHelpers.GetSampleCustomer(),
            };

            customers[0].Country = "United States";
            customers[1].Country = "United States";
            customers[2].Country = "United States";

            customers[0].State = "Washington";
            customers[1].State = "Alaska";
            customers[2].State = "Alaska";

            StatsViewModel viewModel = new StatsViewModel(customers);

            viewModel.SelectedStatsType = StatsType.Location;

            List <Tuple <string, decimal, decimal> > expectedList = new List <Tuple <string, decimal, decimal> >()
            {
                new Tuple <string, decimal, decimal>("United States, Alaska", 2, 66.67m),
                new Tuple <string, decimal, decimal>("United States, Washington", 1, 33.33m),
            };

            CollectionAssert.AreEquivalent(expectedList, viewModel.StatsDataPercent);
        }
        public ActionResult Index(StatsFilterModel filterModel)
        {
            StatsViewModel vm = new StatsViewModel();
            DateTime       dateTo;
            DateTime       dateFrom;

            if (DateTime.TryParseExact(filterModel.S_DateFrom, DATE_PATTERN, null, DateTimeStyles.None, out dateFrom) &&
                DateTime.TryParseExact(filterModel.S_DateTo, DATE_PATTERN, null, DateTimeStyles.None, out dateTo))
            {
                if (dateTo >= dateFrom)
                {
                    vm             = _statsService.GetStats(dateFrom, dateTo);
                    vm.FilterModel = filterModel;
                }
                else
                {
                    AddToastMessage("Błąd", "Data do musi po dacie do", ToastType.Error);
                }
            }
            else
            {
                AddToastMessage("Błąd", "Niewłaściwy format daty", ToastType.Error);
            }

            return(View(GetIndexViewModel(vm)));
        }
        public async Task <IActionResult> TakeTurnAsync(int guess)
        {
            var playerId = Guid.Parse(HttpContext.Session.GetString("PlayerId"));
            var client   = new HttpClient();
            var response = await client.PostAsJsonAsync($"https://localhost:44326/api/players/{playerId}/game/turn", guess);

            var result = await response.Content.ReadAsAsync <Result>();

            if (!result.IsGameCompleted)
            {
                ViewData["Hint"]     = $"You had {result.NrOfCows} cows, {result.NrOfChickens} chickens.";
                ViewData["GameInfo"] = HttpContext.Session.GetString("GameInfo");
                return(View("Game"));
            }
            else
            {
                var statsModel         = new StatsViewModel();
                var efficiencyResponse = await client.GetAsync($"https://localhost:44326/api/players/{playerId}/efficiency");

                statsModel.EfficiencyStats = await efficiencyResponse.Content.ReadAsAsync <Dictionary <int, Stats> >();

                var speedResponse = await client.GetAsync($"https://localhost:44326/api/players/{playerId}/speed");

                statsModel.SpeedStats = await speedResponse.Content.ReadAsAsync <Stats>();

                return(View("GameStats", statsModel));
            }
        }
Esempio n. 11
0
        public StatsPage()
        {
            InitializeComponent();

            viewModel           = new StatsViewModel();
            this.BindingContext = viewModel;
        }
Esempio n. 12
0
 public StatsPage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     BindingContext       = ViewModel = new StatsViewModel();
     ViewModel.Navigation = Navigation;
 }
Esempio n. 13
0
        public void StatsByCategoryReturnCorrectNumberOfUsersPerCategory()
        {
            List <Customer> customers = TestHelpers.GetSampleCustomersList();

            StatsViewModel viewModel = new StatsViewModel(customers);

            viewModel.SelectedStatsType = StatsType.Category;

            List <KeyValuePair <string, decimal> > expectedList = new List <KeyValuePair <string, decimal> >()
            {
                new KeyValuePair <string, decimal>("A", 2),
                new KeyValuePair <string, decimal>("B", 2),
            };

            CollectionAssert.AreEquivalent(expectedList, viewModel.StatsData);

            List <KeyValuePair <string, decimal> > incorrectList = new List <KeyValuePair <string, decimal> >()
            {
                new KeyValuePair <string, decimal>("A", 1),
                new KeyValuePair <string, decimal>("B", 1),
                new KeyValuePair <string, decimal>("C", 1),
            };

            CollectionAssert.AreNotEquivalent(incorrectList, viewModel.StatsData);
        }
Esempio n. 14
0
        // GET: Statistics
        public async Task <ActionResult> Index(string id)
        {
            // get the data
            var user = await userRepo.GetUserById(id);

            var topUsersSent = await userRepo.TopUsersSent(id);

            var topCountsSent = await userRepo.TopCountsSent(id);

            var topUsersReceived = await userRepo.TopUsersReceived(id);

            var topCountsReceived = await userRepo.TopCountsReceived(id);

            var messagesCount = await msgRepo.MessagesCountForStatistics(id);

            // apply the data
            StatsViewModel model = new StatsViewModel
            {
                Id                = user.Id,
                UserName          = user.UserName,
                Avatar            = user.Avatar,
                TopUsersSent      = topUsersSent,
                TopCountsSent     = topCountsSent,
                TopUsersReceived  = topUsersReceived,
                TopCountsReceived = topCountsReceived,
                MessagesCount     = messagesCount
            };

            return(View(model));
        }
Esempio n. 15
0
        // GET: Stats
        public ActionResult Index()
        {
            // Set data using parameters
            var statsViewModel = new StatsViewModel {
                LastDayUpdates = 1, LastWeekUpdates = 5, LastMonthUpdates = 20
            };

            using (var db = new ApplicationDbContext()) {
                // Get songs stats
                var yesterdaySongsCount = db.Songs.Count(s => DbFunctions.DiffDays(s.UploadTime, DateTime.Today) < 1);
                var lastWeekSongsCount  = db.Songs.Count(s => DbFunctions.DiffDays(s.UploadTime, DateTime.Today) < 7);
                var lastMonthSongsCount = db.Songs.Count(s => DbFunctions.DiffDays(s.UploadTime, DateTime.Today) < 30);

                // Get videos stats
                var yesterdayVideosCount = db.Videos.Count(s => DbFunctions.DiffDays(s.UploadTime, DateTime.Today) < 1);
                var lastWeekVideosCount  = db.Videos.Count(s => DbFunctions.DiffDays(s.UploadTime, DateTime.Today) < 7);
                var lastMonthVideosCount = db.Videos.Count(s => DbFunctions.DiffDays(s.UploadTime, DateTime.Today) < 30);

                // Set data using properties
                statsViewModel.LastDayUpdates   = yesterdaySongsCount + yesterdayVideosCount;
                statsViewModel.LastWeekUpdates  = lastWeekSongsCount + lastWeekVideosCount;
                statsViewModel.LastMonthUpdates = lastMonthSongsCount + lastMonthVideosCount;
            }

            return(View(statsViewModel));
        }
Esempio n. 16
0
        public StatsPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new StatsViewModel();
            MessagingCenter.Subscribe <MenuViewModel>(this, "LangRefresh", Refresh);
        }
        // GET: Stats
        public ActionResult Index()
        {
            StatsViewModel vm = new StatsViewModel();

            CourseRepository courseRepository = new CourseRepository();
            var courses     = courseRepository.GetAll();
            int courseCount = courses.Count();

            vm.CoursesCount = courseCount;

            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers     = trainerRepository.GetAll();
            int trainerCount = trainers.Count();

            vm.TrainersCount = trainerCount;

            AssignmentRepository assignmentRepository = new AssignmentRepository();
            var assignments     = assignmentRepository.GetAll();
            int assignmentCount = assignments.Count();

            vm.AssignmentsCount = assignmentCount;

            StudentRepository studentRepository = new StudentRepository();
            var students     = studentRepository.GetAll();
            int studentCount = students.Count();

            vm.StudentsCount = studentCount;

            vm.CourseTable = courses;

            return(View(vm));
        }
Esempio n. 18
0
        public void StatsByLocationReturnCorrectNumberOfUsersPerLocation()
        {
            List <Customer> customers = TestHelpers.GetSampleCustomersList();

            StatsViewModel viewModel = new StatsViewModel(customers);

            viewModel.SelectedStatsType = StatsType.Location;

            List <KeyValuePair <string, decimal> > expectedList = new List <KeyValuePair <string, decimal> >()
            {
                new KeyValuePair <string, decimal>("United States, Alaska", 2),
                new KeyValuePair <string, decimal>("United States, Florida", 1),
                new KeyValuePair <string, decimal>("United States, Washington", 1),
            };

            CollectionAssert.AreEquivalent(expectedList, viewModel.StatsData);

            List <KeyValuePair <string, decimal> > incorrectList = new List <KeyValuePair <string, decimal> >()
            {
                new KeyValuePair <string, decimal>("UK, Surrey", 1),
                new KeyValuePair <string, decimal>("United States, Florida", 1),
                new KeyValuePair <string, decimal>("United States, Washington", 1),
            };

            CollectionAssert.AreNotEquivalent(incorrectList, viewModel.StatsData);
        }
Esempio n. 19
0
        public void StatsByLocationPercentShouldToupleWithDescriptionValuePercentage()
        {
            List <Customer> customers = TestHelpers.GetSampleCustomersList();

            StatsViewModel viewModel = new StatsViewModel(customers);

            viewModel.SelectedStatsType = StatsType.Location;

            List <Tuple <string, decimal, decimal> > expectedList = new List <Tuple <string, decimal, decimal> >()
            {
                new Tuple <string, decimal, decimal>("United States, Alaska", 2, 50),
                new Tuple <string, decimal, decimal>("United States, Florida", 1, 25),
                new Tuple <string, decimal, decimal>("United States, Washington", 1, 25)
            };

            CollectionAssert.AreEquivalent(expectedList, viewModel.StatsDataPercent);

            List <Tuple <string, decimal, decimal> > incorrectList = new List <Tuple <string, decimal, decimal> >()
            {
                new Tuple <string, decimal, decimal>("United States, Alaska", 2, 0),
                new Tuple <string, decimal, decimal>("United States, Florida", 1, 0),
                new Tuple <string, decimal, decimal>("United States, Washington", 1, 0)
            };

            CollectionAssert.AreNotEquivalent(incorrectList, viewModel.StatsData);
        }
Esempio n. 20
0
        public StatsUC()
        {
            InitializeComponent();
            StatsViewModel vm = new StatsViewModel(this);

            DataContext = vm;
        }
 public ActionResult NewDate(StatsViewModel model, int deltaStart, int deltaEnd)
 {
     model.Start = model.Start.AddDays(deltaStart);
     model.End   = model.End.AddDays(deltaEnd);
     GetData(model);
     return(View("Index", model));
 }
Esempio n. 22
0
        public async Task <IActionResult> Stats()
        {
            StatsViewModel model = new StatsViewModel();

            model.playlists = await _playlistEntity.GetAllUserPlaylists(SessionState.GetCurrUserID(User));

            return(View(model));
        }
Esempio n. 23
0
        public IActionResult Filter(
            StatsViewModel viewModel)
        {
            viewModel.Raspberrys = GetRaspberryStatsViewModel(
                viewModel.DateToFilter);

            return(View("index", viewModel));
        }
Esempio n. 24
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += StatsView_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;

            DataContext = new StatsViewModel(new DialogService());
        }
        // GET: Stats
        public ActionResult Index()
        {
            var model = new StatsViewModel();

            model.Start = DateTime.Today.Subtract(TimeSpan.FromDays(7));
            model.End   = DateTime.Today;
            GetData(model);
            return(View(model));
        }
Esempio n. 26
0
 public static Stats Map(StatsViewModel model)
 {
     return(new Stats()
     {
         count_mutant_dna = model.mutant,
         count_human_dna = model.human,
         ratio = model.ratio,
     });
 }
        async void ToolbarItem_Clicked(object sender, EventArgs e)
        {
            //TODO: Create new page for showing stats. Passes the found WorkDays in this viewmodel into the StatsViewModel
            var workDaysList   = viewModel.WorkDays.ToList();
            var statsViewModel = new StatsViewModel(workDaysList);

            await Navigation.PushAsync(
                new StatsPage(statsViewModel));
        }
Esempio n. 28
0
        public static StatsViewModel GenerateStats(DateRange period)
        {
            StatsViewModel result = new StatsViewModel();

            result.header = GenerateStatsSubHeader(period.dateFrom != null ? period.dateFrom.Value : DateTime.MinValue, period.dateTo != null ? period.dateTo.Value : DateTime.Today);
            result.body   = GenerateStatsBody(period);

            return(result);
        }
Esempio n. 29
0
        // GET: Stats
        public ActionResult Index()
        {
            StatsViewModel stats = new StatsViewModel();

            stats.BattingStats = LoadBattingStats();
            stats.BowlingStats = LoadBowlingStats();

            return(View(stats));
        }
        public StatsDetail()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            SizeChanged += OnSizeChanged;

            StatsModel = new StatsViewModel();
        }
        // GET: Stats
        public ActionResult Index()
        {
            StatsViewModel vm = new StatsViewModel();

            StudentRepository studentRepository = new StudentRepository();
            var students = studentRepository.GetAll();

            CourseRepository courseRepository = new CourseRepository();
            var courses = courseRepository.GetAll();

            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();

            AssignmentRepository assignmentRepository = new AssignmentRepository();
            var assignments = assignmentRepository.GetAll();

            vm.StudentsCount    = students.Count();
            vm.CoursesCount     = courses.Count();
            vm.TrainersCount    = trainers.Count();
            vm.AssignmentsCount = assignments.Count();

            //Grouping Course Student
            vm.StudentsPerCourse = students
                                   .SelectMany(x => x.Courses.Select(y => new
            {
                Key   = y,
                Value = x
            }))
                                   .GroupBy(y => y.Key, x => x.Value);

            //Grouping Course Trainer
            vm.TrainersPerCourse = trainers
                                   .SelectMany(x => x.Courses.Select(y => new
            {
                Key   = y,
                Value = x
            }))
                                   .GroupBy(y => y.Key, x => x.Value);

            //Grouping Course Assignment
            vm.AssignmentPerCourse = courses
                                     .SelectMany(x => x.Assignments.Select(y => new
            {
                Key   = x,
                Value = y
            }))
                                     .GroupBy(y => y.Key, x => x.Value);

            vm.Students    = students;
            vm.Courses     = courses;
            vm.Assignments = assignments;



            return(View(vm));
        }
Esempio n. 32
0
        public StatsViewModelTests()
        {
            SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext());

            this.testScheduler = new TestScheduler();
            this.messenger = new TestMessenger();
            this.logSource = new Mock<ILogSource>();
            this.logSource.SetupGet(x => x.Records).Returns(this.records.ObserveOn(this.testScheduler));

            Messenger.OverrideDefault(this.messenger);

            this.viewModel = new StatsViewModel {
                Scheduler = this.testScheduler,
                LogSourceInfo = new LogSourceInfo(this.logSource.Object, null, false, false)
            };
        }
Esempio n. 33
0
        public void ComputeStatsForQuartal(IReadOnlyCollection<Report> reportsForQuartal, StatsViewModel vm)
        { 
            List<StatsViewModel.Chart.ChartRow> chart = new List<StatsViewModel.Chart.ChartRow>();

            var currentMonthQuery = reportsForQuartal.Where(report => report.DateHappened.Month == DateTime.Now.Month);
            var monthQuery = currentMonthQuery as Report[] ?? currentMonthQuery.ToArray();

            var currentMonthCompleted  = monthQuery.Count(report => report.Status == ReportStatus.Completed);
            var currentMonthCreated    = monthQuery.Count(report => report.Status == ReportStatus.Created);
            var currentMonthProcessing = monthQuery.Count(report => report.Status == ReportStatus.Processing);
            var currentMonthFails      = monthQuery.Count(report => report.Status == ReportStatus.Failure);
            var currentMonthSummary    = monthQuery.Count();

            vm.ThisMonthNumbers = new StatsViewModel.Numbers
            {
                ReportsCount      = currentMonthSummary,
                ReportsCreated    = currentMonthCreated,
                ReportsCompleted  = currentMonthCompleted,
                ReportsProcessing = currentMonthProcessing,
                ReportsFailed     = currentMonthFails
            };
            vm.ThisMonthPercentages = new StatsViewModel.Percentages
            {
                AverageReportsCompleted  = (double)currentMonthCompleted  / (currentMonthSummary) * 100.0,
                AverageReportsProcessing = (double)currentMonthProcessing / (currentMonthSummary) * 100.0,
                AverageReportsFailure    = (double)currentMonthFails      / (currentMonthSummary) * 100.0
            };
            
            var offset = TimeSpan.FromDays(30);

            chart.Add(BuildChartRow(reportsForQuartal, DateTime.Now));

            for (int i = 0; i < 3; i++)
            {
                chart.Add(BuildChartRow(reportsForQuartal, DateTime.Now - offset));
                offset += TimeSpan.FromDays(30);
            }
            vm.ReportsChart = chart.AsReadOnly();
        }
Esempio n. 34
0
        public ActionResult BasicStats()
        {
            var lostPetsCount = this.Cache
                .Get(
                "lostPetsCount",
                () => this.postsService.All(false, "изгубени").ToList().Count,
                30 * 60);

            var foundPetsCount = this.Cache
                .Get(
                "foundPetsCount",
                () => this.postsService.All(false, "намерени").ToList().Count,
                30 * 60);

            var solvedCases = this.Cache
                .Get(
                "solvedCases",
                () => this.postsService.All(true, string.Empty).ToList().Count,
                30 * 60);

            var data = new StatsViewModel { LostPets = lostPetsCount, FoundPets = foundPetsCount, SolvedCases = solvedCases };

            return this.PartialView("_StatsPartial", data);
        }
Esempio n. 35
0
 public StatsViewModel ComputeStats(IReadOnlyCollection<Report> userReports)
 {
     var vm = new StatsViewModel();
     var orderedReports = userReports
         .OrderByDescending(report => report.Timestamp)
         .ToList()
         .AsReadOnly();
     ComputeStatsForAllTime(orderedReports, vm);
     ComputeStatsForQuartal(orderedReports, vm);
     return vm;
 }
Esempio n. 36
0
        public ActionResult Index()
        {
            var statistic = new StatsViewModel()
            {
                OverallNewsCount = articlesRepository.GetAll().Count(),
                LastWeekNewsCount = articlesRepository.GetAll().Count(art => art.PostedAt > DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0))),
                OverallEventsCount = eventsRepository.GetAll().Count(),
                FollowingEvents = eventsRepository.GetAll().Count(ev => ev.Date > DateTime.Now)
            };

            return View(statistic);
        }