示例#1
0
        public IActionResult Product(Comment comment)
        {
            var product = ps.GetProductById(comment.ProductId);

            if (!ModelState.IsValid)
            {
                if (product == null)
                {
                    return(RedirectToAction("index"));
                }
                return(View(new ProductDetaileVM {
                    Product = product
                }));
            }
            if (comment.Rate > 5)
            {
                comment.Rate = 5;
            }
            else if (comment.Rate < 1)
            {
                comment.Rate = 1;
            }
            ps.RateToProduct(new Models.DataBase.Dto.Frount.Rate {
                UserId = "ergerg", Rateing = comment.Rate
            }, comment.ProductId);
            var result = ps.AddComment(new Models.DataBase.Entities.Comment
            {
                CommentedDate = DateTime.Now,
                CommentText   = comment.CommentText,
                Email         = comment.Email,
                FullName      = comment.Name,
                ProductId     = comment.ProductId,
                IsSeen        = false,
                IsShow        = false,
                IsVerified    = false
            });

            if (result)
            {
                ViewBag.msg     = "از اینکه این محصول را نقد کردید، سپاسگذاریم";
                ViewBag.success = true;
            }
            else
            {
                ViewBag.msg     = "متاسفانه بنا به دلایلی نقد شما ثبت نشد!";
                ViewBag.success = false;
            }
            ProductDetaileVM detaileVM = new ProductDetaileVM {
                Product = product
            };

            return(RedirectToAction("Product", "Home", product.EName));
        }
示例#2
0
        public IActionResult Product(string Name)
        {
            if (Name == null || Name == "")
            {
                return(RedirectToAction("index"));
            }
            var product = ps.GetProductByEname(Name);

            if (product == null)
            {
                return(RedirectToAction("index"));
            }
            ProductDetaileVM detaileVM = new ProductDetaileVM {
                Product = product
            };

            return(View(detaileVM));
        }