예제 #1
0
        async Task SubmitReview()
        {
            if (string.IsNullOrWhiteSpace(FullName) ||
                string.IsNullOrWhiteSpace(Email) ||
                string.IsNullOrWhiteSpace(Location) ||
                string.IsNullOrWhiteSpace(Description))
            {
                return;
            }

            ProductReviewViewModel newReview = new ProductReviewViewModel()
            {
                ProductID   = Product.ID,
                FullName    = this.FullName,
                Email       = this.Email,
                Location    = this.Location,
                Description = this.Description,
                Rating      = getRating()
            };

            setRatingStars(newReview);
            FullName    = "";
            Email       = "";
            Location    = "";
            Description = "";

            await productService.CreateProductReview(newReview);

            ProductReviews.Insert(ProductReviews.Count, newReview);
        }
예제 #2
0
        /// <summary>
        /// 商品评价列表
        /// </summary>
        public ActionResult ProductReviewList()
        {
            int pid        = WebHelper.GetQueryInt("pid");
            int reviewType = WebHelper.GetQueryInt("reviewType");
            int page       = WebHelper.GetQueryInt("page");

            //判断商品是否存在
            PartProductInfo productInfo = Products.GetPartProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            if (reviewType < 0 || reviewType > 3)
            {
                reviewType = 0;
            }

            PageModel pageModel          = new PageModel(10, page, ProductReviews.GetProductReviewCount(pid, reviewType));
            ProductReviewListModel model = new ProductReviewListModel()
            {
                ProductInfo       = productInfo,
                CategoryInfo      = Categories.GetCategoryById(productInfo.CateId),
                BrandInfo         = Brands.GetBrandById(productInfo.BrandId),
                ReviewType        = reviewType,
                PageModel         = pageModel,
                ProductReviewList = ProductReviews.GetProductReviewList(pid, reviewType, pageModel.PageSize, pageModel.PageNumber)
            };

            return(View(model));
        }
예제 #3
0
        public ActionResult Index(int id, string name, string email, int rate, string message, int?page)
        {
            ProductReviews reviews = new ProductReviews();

            reviews.AddReview(id, name, email, rate, message);

            Category category = new Category();

            ViewBag.Category = category.GetCategories();

            Item item = new Item();
            var  data = item.GetItemById(id);

            ViewBag.Item = data;

            IEnumerable <DbProductReview> review = reviews.GetReview(id);

            ViewBag.SameItems = item.GetSameItems(data.Category);

            string returnUrl = Request.UrlReferrer.AbsolutePath;

            int pageSize   = 5;
            int pageNumber = (page ?? 1);

            return(View(review.ToPagedList(pageNumber, pageSize)));
        }
예제 #4
0
        /// <summary>
        /// 商品评价列表
        /// </summary>
        public ActionResult ProductReviewList()
        {
            int pid        = WebHelper.GetQueryInt("pid");
            int reviewType = WebHelper.GetQueryInt("reviewType");
            int page       = WebHelper.GetQueryInt("page");

            //判断商品是否存在
            PartProductInfo productInfo = Products.GetPartProductById(pid);

            if (productInfo == null)
            {
                return(PromptView(Url.Action("index", "home"), "你访问的商品不存在"));
            }

            if (reviewType < 0 || reviewType > 3)
            {
                reviewType = 0;
            }

            PageModel pageModel          = new PageModel(10, page, ProductReviews.GetProductReviewCount(pid, reviewType));
            ProductReviewListModel model = new ProductReviewListModel()
            {
                ProductInfo       = productInfo,
                ReviewType        = reviewType,
                PageModel         = pageModel,
                ProductReviewList = ProductReviews.GetProductReviewList(pid, reviewType, pageModel.PageSize, pageModel.PageNumber)
            };

            return(View(model));
        }
예제 #5
0
        public async Task <IActionResult> Create([FromBody] CreateProductReviewRequest productReviewRequest)
        {
            var ProdReview = new ProductReviews
            {
                ArabicDescreption  = productReviewRequest.ArabicDescreption,
                EnglishDescreption = productReviewRequest.EnglishDescreption,
                ProductId          = productReviewRequest.ProductId,
                UserId             = productReviewRequest.UserId,
                Rate      = productReviewRequest.Rate,
                Status    = 0,
                CreatedAt = System.DateTime.Now
            };

            var status = await _productReviewService.CreateProductReviewAsync(ProdReview);

            if (status == 1)
            {
                var response = new ProductReviewResponse {
                    Id = ProdReview.Id
                };
                return(Ok(response));
            }
            return(BadRequest(new ErrorResponse
            {
                message = "Internal Server Error",
                status = BadRequest().StatusCode
            }));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ProductReviews productReviews = db.ProductReviews.Find(id);

            db.ProductReviews.Remove(productReviews);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #7
0
        public async Task <int> CreateProductReviewAsync(ProductReviews productReviews)
        {
            await _dataContext.ProductReviews.AddAsync(productReviews);

            var created = await _dataContext.SaveChangesAsync();

            return(created);
        }
 public ActionResult Edit([Bind(Include = "Rid,ReviewMsg,ProducctID,Custid,StarCount,IsActive,IsDelete,IsUpdate,InsertDate,LMDDate")] ProductReviews productReviews)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productReviews).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productReviews));
 }
        public ActionResult Create([Bind(Include = "Rid,ReviewMsg,ProducctID,Custid,StarCount,IsActive,IsDelete,IsUpdate,InsertDate,LMDDate")] ProductReviews productReviews)
        {
            if (ModelState.IsValid)
            {
                db.ProductReviews.Add(productReviews);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productReviews));
        }
예제 #10
0
        public ActionResult DeleteReview(int reviewId, int itemId)
        {
            ProductReviews reviews = new ProductReviews();

            reviews.DeleteReview(reviewId);

            AdminItem product = new AdminItem();
            var       data    = product.ItemInfo(itemId);

            return(PartialView(data));
        }
        // GET: ProductReviews/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductReviews productReviews = db.ProductReviews.Find(id);

            if (productReviews == null)
            {
                return(HttpNotFound());
            }
            return(View(productReviews));
        }
예제 #12
0
        /// <summary>
        /// 执行事件
        /// </summary>
        /// <param name="eventInfo">事件信息</param>
        public void Execute(object eventInfo)
        {
            EventInfo e = (EventInfo)eventInfo;

            //同步商品评价数量
            DateTime  lastExecuteTime = EventLogs.GetEventLastExecuteTimeByKey(e.Key);
            DataTable dt = ProductReviews.GetProductReviewList(lastExecuteTime, DateTime.Now);

            foreach (DataRow row in dt.Rows)
            {
                int pid      = TypeHelper.ObjectToInt(row["pid"]);
                int starType = TypeHelper.ObjectToInt(row["star"]);
                Products.AddProductShadowReviewCount(pid, starType);
            }

            EventLogs.CreateEventLog(e.Key, e.Title, Environment.MachineName, DateTime.Now);
        }
예제 #13
0
        /// <summary>
        /// 商品评价列表
        /// </summary>
        public ActionResult ProductReviewList()
        {
            int pid        = WebHelper.GetQueryInt("pid");
            int reviewType = WebHelper.GetQueryInt("reviewType");
            int page       = WebHelper.GetQueryInt("page");

            //判断商品是否存在
            PartProductInfo productInfo = Products.GetPartProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            if (reviewType < 0 || reviewType > 3)
            {
                reviewType = 0;
            }

            PageModel pageModel          = new PageModel(10, page, ProductReviews.GetProductReviewCount(pid, reviewType));
            ProductReviewListModel model = new ProductReviewListModel()
            {
                ProductInfo       = productInfo,
                CategoryInfo      = Categories.GetCategoryById(productInfo.CateId),
                BrandInfo         = Brands.GetBrandById(productInfo.BrandId),
                StoreInfo         = storeInfo,
                StoreKeeperInfo   = Stores.GetStoreKeeperById(storeInfo.StoreId),
                StoreRegion       = Regions.GetRegionById(storeInfo.RegionId),
                StoreRankInfo     = StoreRanks.GetStoreRankById(storeInfo.StoreRid),
                ReviewType        = reviewType,
                PageModel         = pageModel,
                ProductReviewList = ProductReviews.GetProductReviewList(pid, reviewType, pageModel.PageSize, pageModel.PageNumber)
            };

            return(View(model));
        }
예제 #14
0
        /// <summary>
        /// 商品评价列表
        /// </summary>
        public ActionResult AjaxProductReviewList()
        {
            int pid        = WebHelper.GetQueryInt("pid");
            int reviewType = WebHelper.GetQueryInt("reviewType");
            int page       = WebHelper.GetQueryInt("page");

            if (reviewType < 0 || reviewType > 3)
            {
                reviewType = 0;
            }

            PageModel pageModel = new PageModel(10, page, ProductReviews.GetProductReviewCount(pid, reviewType));
            AjaxProductReviewListModel model = new AjaxProductReviewListModel()
            {
                Pid               = pid,
                ReviewType        = reviewType,
                PageModel         = pageModel,
                ProductReviewList = ProductReviews.GetProductReviewList(pid, reviewType, pageModel.PageSize, pageModel.PageNumber)
            };

            return(View(model));
        }
예제 #15
0
        // GET: Item
        public ActionResult Index(int id, int?page)
        {
            Category category = new Category();

            ViewBag.Category = category.GetCategories();

            Item item = new Item();
            var  data = item.GetItemById(id);

            ViewBag.Item = data;

            ProductReviews reviews = new ProductReviews();

            IEnumerable <DbProductReview> review = reviews.GetReview(id);

            ViewBag.SameItems = item.GetSameItems(data.Category);

            int pageSize   = 5;
            int pageNumber = (page ?? 1);

            return(View(review.ToPagedList(pageNumber, pageSize)));
        }
예제 #16
0
 public static ProductReviews ToEntity(this ProductReviewModel model, ProductReviews destination)
 {
     return(Mapper.Map(model, destination));
 }
예제 #17
0
 public static ProductReviewModel ToModel(this ProductReviews entity)
 {
     return(Mapper.Map <ProductReviews, ProductReviewModel>(entity));
 }
예제 #18
0
        /// <summary>
        /// 评价商品
        /// </summary>
        public ActionResult ReviewProduct()
        {
            int    oid      = WebHelper.GetQueryInt("oid");       //订单id
            int    recordId = WebHelper.GetQueryInt("recordId");  //订单商品记录id
            int    star     = WebHelper.GetFormInt("star");       //星星
            string message  = WebHelper.GetFormString("message"); //评价内容

            if (star > 5 || star < 0)
            {
                return(AjaxResult("wrongstar", "请选择正确的星星"));
            }

            if (message.Length == 0)
            {
                return(AjaxResult("emptymessage", "请填写评价内容"));
            }
            if (message.Length > 100)
            {
                return(AjaxResult("muchmessage", "评价内容最多输入100个字"));
            }
            //禁止词
            string bannedWord = FilterWords.GetWord(message);

            if (bannedWord != "")
            {
                return(AjaxResult("bannedWord", "评价内容中不能包含违禁词"));
            }

            OrderInfo orderInfo = Orders.GetOrderByOid(oid);

            if (orderInfo == null || orderInfo.Uid != WorkContext.Uid)
            {
                return(AjaxResult("noexistorder", "订单不存在"));
            }
            if (orderInfo.OrderState != (int)OrderState.Completed)
            {
                return(AjaxResult("nocomplete", "订单还未完成,不能评价"));
            }

            OrderProductInfo        orderProductInfo = null;
            List <OrderProductInfo> orderProductList = Orders.GetOrderProductList(oid);

            foreach (OrderProductInfo item in orderProductList)
            {
                if (item.RecordId == recordId)
                {
                    orderProductInfo = item;
                    break;
                }
            }
            if (orderProductInfo == null)
            {
                return(AjaxResult("noproduct", "商品不存在"));
            }
            //商品已评价
            if (orderProductInfo.IsReview == 1)
            {
                return(AjaxResult("reviewed", "商品已经评价"));
            }

            int payCredits = Credits.SendReviewProductCredits(ref WorkContext.PartUserInfo, orderProductInfo, DateTime.Now);
            ProductReviewInfo productReviewInfo = new ProductReviewInfo()
            {
                Pid        = orderProductInfo.Pid,
                Uid        = orderProductInfo.Uid,
                OPRId      = orderProductInfo.RecordId,
                Oid        = orderProductInfo.Oid,
                ParentId   = 0,
                State      = 0,
                Star       = star,
                Quality    = 0,
                Message    = WebHelper.HtmlEncode(FilterWords.HideWords(message)),
                ReviewTime = DateTime.Now,
                PayCredits = payCredits,
                PName      = orderProductInfo.Name,
                PShowImg   = orderProductInfo.ShowImg,
                BuyTime    = orderProductInfo.AddTime,
                IP         = WorkContext.IP
            };

            ProductReviews.ReviewProduct(productReviewInfo);

            orderProductInfo.IsReview = 1;
            if (Orders.IsReviewAllOrderProduct(orderProductList))
            {
                Orders.UpdateOrderIsReview(oid, 1);
            }

            return(AjaxResult("success", recordId.ToString()));
        }
예제 #19
0
        public IActionResult Create(int id)
        {
            ProductReviews productReviews = new ProductReviews(id);

            return(View(productReviews));
        }