コード例 #1
0
        public ActionResult ShowRating(int ProductID)
        {
            ProductRatingViewModel objProductRatingViewModel = new ProductRatingViewModel();
            if (repository.CheckProductExist(ProductID) == true)
            {
                objProductRatingViewModel.AverageRating = repository.AverageRating(ProductID);
                objProductRatingViewModel.Voters = repository.Voters(ProductID);
                if (Request.Cookies["rating" + repository.GetID(ProductID, User.Identity.GetUserId())] != null)
                {
                    objProductRatingViewModel.CanUserVote = false;
                    objProductRatingViewModel.UserRating = repository.UserRating(User.Identity.GetUserId(), ProductID);
                }
                else
                {
                    objProductRatingViewModel.CanUserVote = true;
                }

            }

            else
            {
                objProductRatingViewModel.CanUserVote = true;

            }

            return View(objProductRatingViewModel);
        }
コード例 #2
0
 public ActionResult OnlyDisplayRating(int ProductID)
 {
     ProductRatingViewModel objProductRatingViewModel = new ProductRatingViewModel();
     if (repository.CheckProductExist(ProductID) == true)
     {
         objProductRatingViewModel.AverageRating = repository.AverageRating(ProductID);
     }
     else
     {
         objProductRatingViewModel.AverageRating = 0;
     }
     return View(objProductRatingViewModel);
 }
コード例 #3
0
        public JsonResult SaveRating(ProductRatingViewModel objProductRatingViewModel)
        {
            //int number =
            //int ProductID = Convert.ToInt32(FormCollection["ProductID"]);

            ProductsRating objProductsRating = new ProductsRating();
            objProductsRating.ProductID = objProductRatingViewModel.ProductID;
            objProductsRating.ProductRatings = objProductRatingViewModel.ProductRatings;

            objProductsRating.ApplicationUserID = User.Identity.GetUserId();
            repository.Insert(objProductsRating);
            repository.Save();

            HttpCookie cookie = new HttpCookie("rating" + repository.GetID(objProductRatingViewModel.ProductID, User.Identity.GetUserId()));
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddYears(1);
            Response.Cookies.Add(cookie);

            objProductRatingViewModel.AverageRating = repository.AverageRating(objProductRatingViewModel.ProductID);
            objProductRatingViewModel.Voters = repository.Voters(objProductRatingViewModel.ProductID);

            return Json(objProductRatingViewModel);
        }
コード例 #4
0
        // Quick Search AutoComplelete
        public ActionResult TestAction()
        {
            ProductRatingViewModel objProductRatingViewModel = new ProductRatingViewModel();

            return View();
        }