예제 #1
0
        public virtual ActionResult SendComment(DetailsProductShowViewModel model)
        {
            var userId     = User.Identity.GetUserId <int>();
            var product_Id = model.ProductShowViewModel.Id;

            if (_productService.IsExistById(product_Id))
            {
                var comment = new Comment()
                {
                    User_Id = userId, DateTimeComment = DateTime.Now, DisplayStatus = false, Explain = model.SendCommentViewModel.Explain.Replace("\r\n", "<br />").ToSafeHtml(), Product_Id = product_Id
                };
                _commentService.Create(comment);
                if (_unitOfWork.SaveAllChanges() > 0)
                {
                    return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel {
                        Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessSendComment), Status = AlertMode.success
                    }));
                }
                else
                {
                    return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel {
                        Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendComment), Status = AlertMode.warning
                    }));
                }
            }
            else
            {
                return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel {
                    Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendComment), Status = AlertMode.warning
                }));
            }
        }
예제 #2
0
        public virtual ActionResult DetailSProduct(int?productId, string productName)
        {
            ViewBag.ProductName = productName;
            int id;

            if (int.TryParse(productId.ToString(), out id))
            {
                var model = _productService.GetProductById_(id);
                if (model != null)
                {
                    var modelResult = new DetailsProductShowViewModel();
                    modelResult.ProductShowViewModel = model;
                    modelResult.SendCommentViewModel = new SendCommentViewModel();
                    _productService.IncreaseVisit_(id);
                    return(View(modelResult));
                }
                return(Redirect("/"));
            }
            return(Redirect("/"));
        }