Beispiel #1
0
        public void LogPageView(string contentUId)
        {
            using (var context = new Data.CMSContext()) {
                ContentPageViewCount pageCount = context.ContentPageViewCounts.SingleOrDefault(c => c.ContentUId == contentUId);
                if (pageCount == null)
                {
                    context.ContentPageViewCounts.Add(pageCount = new ContentPageViewCount()
                    {
                        ContentUId = contentUId, Count = 0
                    });
                }

                pageCount.Count++;

                context.SaveChanges();
            }
        }
Beispiel #2
0
        public void LogPageView(string contentUId)
        {
            ContentPageViewCount pageCount = _context.ContentPageViewCounts.SingleOrDefault(c => c.ContentUId == contentUId);

            if (pageCount == null)
            {
                _context.ContentPageViewCounts.Add(pageCount = new ContentPageViewCount()
                {
                    ContentUId = contentUId, Count = 0
                });
            }
            else
            {
                _context.ContentPageViewCounts.Attach(pageCount);
            }

            pageCount.Count++;

            _context.SaveChanges();
        }
Beispiel #3
0
        public void LogPageView(string contentUId)
        {
            using (var context = new Data.CMSContext()) {
                ContentPageViewCount pageCount = context.ContentPageViewCounts.SingleOrDefault(c => c.ContentUId == contentUId);
                if (pageCount == null)
                    context.ContentPageViewCounts.Add(pageCount = new ContentPageViewCount() { ContentUId = contentUId, Count = 0 });

                pageCount.Count++;

                context.SaveChanges();
            }
        }