Ejemplo n.º 1
0
        public bool BlockStart(IEnumerable <IFortranBlock> ancestors, List <FileLine> lines, int lineIndex)
        {
            var parentName = ancestors.FirstOrDefault()?.Name;

            return
                (CommentUtils.NDescStart(lines[lineIndex].Text) &&
                 !(parentName ?? string.Empty).StartsWith("Information_") &&
                 !CommentUtils.InfoStart(lines[lineIndex].Text));
        }
Ejemplo n.º 2
0
        public bool BlockEnd(IEnumerable <IFortranBlock> ancestors, List <FileLine> lines, int lineIndex)
        {
            if (lines.Count == lineIndex + 1)
            {
                return(true);
            }

            return
                (CommentUtils.DescEnd(lines[lineIndex + 1].Text) ||
                 CommentUtils.InfoStart(lines[lineIndex + 1].Text) ||
                 CommentUtils.NDescStart(lines[lineIndex + 1].Text));
        }
 // GET: Comment
 // 打开一个具体菜品的相关评论,ID为菜品在数据库中的编号
 public ActionResult Details(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Models.MenuItem menuItem = db.MenuItems.Find(id);
     if (menuItem == null)
     {
         return(HttpNotFound());
     }
     return(View(CommentUtils.GetCommentModel(menuItem)));
 }
Ejemplo n.º 4
0
        public bool BlockEnd(IEnumerable <IFortranBlock> ancestors, List <FileLine> lines, int lineIndex)
        {
            if (lineIndex + 1 >= lines.Count)
            {
                return(true);
            }

            var parentAncestors = ancestors.Skip(1);

            return
                (CommentUtils.NDescEnd(lines[lineIndex + 1].Text) ||
                 this.BlockStart(parentAncestors, lines, lineIndex + 1) ||
                 CommentUtils.InfoStart(lines[lineIndex + 1].Text));
        }
        // “添加评论”功能,返回一张空白评论表,评论内容为对应订单的所有菜品
        public ActionResult OrderComment(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MenuOrder        menuOrder    = db.MenuOrders.Find(id);
            UserCommentModel commentModel = CommentUtils.GetBlankCommentModel(menuOrder);

            Session["OrderDetails"] = commentModel;
            if (menuOrder == null)
            {
                return(HttpNotFound());
            }
            return(View(commentModel));
        }
Ejemplo n.º 6
0
        public string GetValue(TableStyle style, Comment comment)
        {
            var value = string.Empty;

            if (comment.ContainsKey(style.AttributeName))
            {
                var fieldValue = comment.Get <string>(style.AttributeName);

                if (style.InputType == InputType.CheckBox || style.InputType == InputType.SelectMultiple)
                {
                    var list = TranslateUtils.JsonDeserialize <List <string> >(fieldValue);
                    if (list != null)
                    {
                        value = string.Join(",", list);
                    }
                }
                else if (style.InputType == InputType.Date)
                {
                    if (!string.IsNullOrEmpty(fieldValue))
                    {
                        var date = CommentUtils.ToDateTime(fieldValue, DateTime.MinValue);
                        if (date != DateTime.MinValue)
                        {
                            value = date.ToString("yyyy-MM-dd");
                        }
                    }
                }
                else if (style.InputType == InputType.DateTime)
                {
                    if (!string.IsNullOrEmpty(fieldValue))
                    {
                        var date = CommentUtils.ToDateTime(fieldValue, DateTime.MinValue);
                        if (date != DateTime.MinValue)
                        {
                            value = date.ToString("yyyy-MM-dd HH:mm");
                        }
                    }
                }
                else
                {
                    value = fieldValue;
                }
            }

            return(value);
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = Request.Url.AbsolutePath;

            // đọc slug từ router
            string        slug    = (string)RouteData.Values["slug"];
            ProductEntity product = productRepository.FindProductBySlug(slug);

            // nếu tìm thấy sp thì sẽ hiển thị thông tin sản phẩm
            // nếu không tìm thấy thì sẽ cho về trang home
            if (product != null)
            {
                if (url.Contains("may-tinh"))
                {
                    url_page.Attributes.Add("href", "/may-tinh");
                    name_page.InnerText = "Máy tính";
                    slug_.Attributes.Add("href", "/may-tinh/" + product.Slug);
                }
                else
                {
                    url_page.Attributes.Add("href", "/phu-kien");
                    name_page.InnerText = "Phụ kiện";
                    slug_.Attributes.Add("href", "/phu-kien/" + product.Slug);
                }

                name_product.InnerText = product.Name;

                bigImg.Attributes.Add("src", product.ListImage[0]);

                __title.InnerText = product.Name;
                // load list image
                string html_img = @"<div class='chuyen' onclick='backImg()' style='display: none;'>
                                          <img src='/static/img/icon/click-left.png' >
                                    </div>";

                int i = 0;
                foreach (string img in product.ListImage)
                {
                    i++; // tạo biến đếm để hiển thì 3 ảnh trong list ảnh, tạm thời để none, sau đấy dùng js để thao tác
                    html_img += @"<img src='" + img + @"' class='small-img " + (i > 3 ? "none" : "") + @"' onclick='showImage(this)' num='" + i + @"'>";
                }
                html_img += @"<div class='chuyen' onclick='nextImg()'>
                                    <img src='/static/img/icon/click-right.png' >
                              </div>";


                list_anh.InnerHtml = html_img;

                name_pro.InnerText = product.Name;
                // url sản phẩm sẽ có dạng: /category-name/slug
                name_pro.Attributes.Add("href", "/" + product.Category + "/" + product.Slug);

                price_new.InnerText = String.Format("{0:0,0}", product.Price * (100 - product.Sale) / 100) + @"₫";
                price_old.InnerText = String.Format("{0:0,0}", product.Price) + @"₫";

                if (product.Quantity <= 0)
                {
                    _status.InnerText = "Hết hàng";
                    _status.Attributes.Add("style", "background: red !important");
                }

                // xử lí lại chỗ miêu tả cấu hình
                product.Info          = product.Info.Replace("\n", "<br>");
                product.Info          = product.Info.Replace("\t", ": ");
                info_detail.InnerHtml = product.Info;

                string html = @"<button id=" + "'btn-add-to-cart' onclick='addToCart(" + product.ID + @")'>Thêm vào giỏ hàng</button>";
                btn_server.InnerHtml = html;

                // load bài viết chi tiết
                PostEntity post = postRepository.FindPostByIDProduct(product.ID);
                if (post == null)
                {
                    post_details.InnerText = "Chưa có bài đánh giá sản phẩm này";
                }
                else
                {                 // gán link ảnh vào trong các thẻ img,  "src='filename'" -> "src='link-image'"
                    for (i = 0; i < post.ListImage.Count; i++)
                    {
                        post.Content = post.Content.Replace("src='filename" + i + "'", "src='" + post.ListImage[i] + "'");
                    }
                    post_details.InnerHtml = post.Content;
                }


                // đọc list comment ra
                CommentOfAPost commentInPost = commentRepository.FindListCommentsOfProduct(product.ID);
                string         htmlComment   = CommentUtils.HTMLComments(commentInPost);
                //List<CommentLevel2Entity> comments = commentRepository.FindCommentsByIDProduct(product.ID);
                //string htmlComment = CommentUtils.HTMLComments(comments);
                list_comment.InnerHtml = htmlComment;


                // add btn send cmt
                //onclick = "sendCommentLevel1(1)"
                btn_send_lv1.Attributes.Add("onclick", "sendCommentLevel1(" + product.ID + ")");
                btn_send_lv1.Attributes.Add("idxx", product.ID.ToString());
            }
            else
            {
                Response.Redirect("/");
            }
        }
Ejemplo n.º 8
0
 public bool BlockStart(IEnumerable <IFortranBlock> ancestors, List <FileLine> lines, int lineIndex)
 {
     return
         (CommentUtils.InfoAtDepthStart(lines[lineIndex].Text, _depth) &&
          !CommentUtils.NDescStart(lines[lineIndex].Text));
 }