Ejemplo n.º 1
0
        public void Log(Product product)
        {
            var catid = Int32.Parse(_categoryService.GetProductCategoriesByProductId(product.Id).Select(x => x.CategoryId).FirstOrDefault().ToString());
            //var pcatid = Int32.Parse(_categoryService.GetProductCategoriesByCategoryId(catid).Select(x => x.CategoryId).FirstOrDefault().ToString());
            int parentCID = Convert.ToInt32(_categoryService.GetCategoryIdByParentid(Convert.ToInt32(catid)));

            if (parentCID == 0)
            {
                parentCID = catid;
            }
            var query = (from p in _MVPRepository.Table
                         where p.ProductId == product.Id
                         select p);

            if (query.Count() == 0)
            {
                MostViewedProduct model = new MostViewedProduct();
                model.ProductId   = product.Id;
                model.count       = 1;
                model.parentcatid = parentCID;
                model.CategoryId  = catid;
                model.CustId      = custid;
                _MVPRepository.Insert(model);
            }
            else
            {
                var model = query.First();
                model.count++;
                _MVPRepository.Update(model);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Logs the specified record.
        /// </summary>
        /// <param name="record">The record.</param>
        public void Log(Product product)
        {
            var query = (from p in _MVPRepository.Table
                         where p.ProductId == product.Id
                         select p);

            if (query.Count() == 0)
            {
                MostViewedProduct model = new MostViewedProduct();
                model.ProductId        = product.Id;
                model.ProductViewCount = 1;
                _MVPRepository.Insert(model);
            }
            else
            {
                var model = query.First();
                model.ProductViewCount++;
                _MVPRepository.Update(model);
            }
        }