Esempio n. 1
0
        public ActionResult Get(int id)
        {
            ShowProductDetiels result = new ShowProductDetiels();

            var product = new Biz.ProductBiz().Get(id);

            result.Product = product;
            double Rate      = product.Rate;
            int    downloads = new Biz.DownloadBiz().GetDownloadCount(id);
            int    comments  = new Biz.CommentBiz().CommnetsCount(id);

            result.Comments = new Biz.CommentBiz().Get(id).OrderByDescending(x => x.DateTime).ToList();
            result.Counts   = new CountsViewModel()
            {
                CommentsCount = comments, DownloadsCount = downloads, RateCounts = Rate
            };

            return(View("SmallProduct", result));
        }
Esempio n. 2
0
        // POST api/<controller>
        public OperationResult Post([FromBody] Comment model)
        {
            var OperationResult = new Biz.CommentBiz().Create(new Comment()
            {
                Description = model.Description, Product_Id = model.Product_Id, UserRate = model.UserRate
            });

            if (!OperationResult.Succeed)
            {
                return(OperationResult);
            }
            else
            {
                double rate = new Biz.CommentBiz().GetRate(model.Product_Id);

                Product product = new Biz.ProductBiz().Get(model.Product_Id);

                product.Rate = rate;
                return(new Biz.ProductBiz().Edit(product));
            }
        }
Esempio n. 3
0
        public ActionResult Create(string description, int productId, int Rate)
        {
            var OperationResult = new Biz.CommentBiz().Create(new Comment()
            {
                Description = description, Product_Id = productId, UserRate = Rate
            });

            if (!OperationResult.Succeed)
            {
                //  Send "false"
                return(Json(new { success = false, responseText = OperationResult.Message }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                double rate = new Biz.CommentBiz().GetRate(productId);

                Product product = new Biz.ProductBiz().Get(productId);

                product.Rate = rate;
                new Biz.ProductBiz().Edit(product);
                //  Send "Success"
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
        }