Exemple #1
0
        public void LogPostView(int postId, string referredUrl, string ipAddress, string userAgent, int?UserId)
        {
            var analyticPostView = new AnalyticPostView
            {
                PostId      = postId,
                ReferredUrl = referredUrl,
                IPAddress   = ipAddress,
                UserAgent   = userAgent,
                UserId      = UserId ?? 0,
                DateAdded   = DateTime.Now
            };

            _context.AnalyticPostViews.Add(analyticPostView);

            _context.SaveChanges();
        }
        public async Task LogPostViewAsync(int postId, string referredUrl, string ipAddress, string userAgent, string UserId)
        {
            var analyticPostView = new AnalyticPostView
            {
                PostId      = postId,
                ReferredUrl = referredUrl,
                IPAddress   = ipAddress,
                UserAgent   = userAgent,
                UserId      = UserId ?? string.Empty,
                DateAdded   = DateTime.Now
            };

            _context.AnalyticPostViews.Add(analyticPostView);

            await _context.SaveChangesAsync();
        }