Пример #1
0
        public ActionResult Index()
        {
            var repo = new VisitsRepository(Properties.Settings.Default.ConStr);

            repo.AddVisit(Request.UserHostAddress);
            var vm = new HomePageViewModel
            {
                FiveMostFrequentIPs = repo.GetFiveMostFrequentIPs(),
                TodayCount          = repo.GetVisitCountForToday(),
                MostPopularIP       = repo.GetMostPopularIpAddress()
            };

            return(View(vm));
        }
Пример #2
0
        public IActionResult Index()
        {
            var repo = new VisitsRepository(_connectionString);
            var ip   = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            if (ip == "::1")
            {
                ip = "127.0.0.1";
            }
            repo.AddVisit(ip);
            var vm = new HomePageViewModel
            {
                FiveMostFrequentIPs = repo.GetFiveMostFrequentIPs(),
                TodayCount          = repo.GetVisitCountForToday(),
                MostPopularIP       = repo.GetMostPopularIpAddress()
            };

            return(View(vm));
        }