示例#1
0
        // GET: Index
        public ActionResult Index()
        {
            string address = Request.UserHostAddress;
            int    type    = repository.CheckIP(address) ? (int)StatisticsHelper.StatisticTypes.Visitor : (int)StatisticsHelper.StatisticTypes.UniqueVisitor;

            string userName = String.IsNullOrEmpty(User.Identity.Name) ? null : User.Identity.Name;
            string email    = userName == null ? null : Membership.GetUser(User.Identity.Name).Email;

            repository.AddStatistic(new CreateStatisticModel
            {
                Type      = type,
                Time      = DateTime.Now,
                IPAddress = address,
                UserName  = userName,
                Email     = email,
            });

            return(View());
        }