コード例 #1
0
        public ActionResult Preview(PageData currentPage, PageListModel bookModel)
        {
            var pd = (BookPage)currentPage;


            var model = new BookItemModel(pd)
            {
                Tags = GetTags(pd),
            };

            return(PartialView("Preview", model));
        }
コード例 #2
0
        public ActionResult Full(BookPage currentPage)
        {
            var model = new BookItemModel(currentPage)
            {
                Category = currentPage.Category,
                Tags     = GetTags(currentPage)
            };

            var editHints = ViewData.GetEditHints <BookItemModel, BookPage>();

            editHints.AddConnection(m => m.Category, p => p.Category);
            editHints.AddFullRefreshFor(p => p.Category);
            editHints.AddFullRefreshFor(p => p.StartPublish);

            return(PartialView("Full", model));
        }
コード例 #3
0
ファイル: CatalogueController.cs プロジェクト: avgx/knigoskop
        private BaseItemModel GetNewItemByType(ItemTypeEnum itemType)
        {
            BaseItemModel result = null;

            switch (itemType)
            {
            case ItemTypeEnum.Author:
                result = new AuthorItemModel();
                break;

            case ItemTypeEnum.Book:
                result = new BookItemModel();
                break;

            case ItemTypeEnum.Serie:
                result = new SerieItemModel();
                break;

            case ItemTypeEnum.Review:
                result = new ReviewItemModel();
                break;
            }
            return(result);
        }
コード例 #4
0
        public ActionResult <ResponseModel> GetInfo(string id)
        {
            var book = new BookItemModel {
                ID = id
            };
            var     url     = "http://product.dangdang.com/" + id + ".html";
            var     html    = @url;
            HtmlWeb web     = new HtmlWeb();
            var     htmlDoc = web.Load(html);
            var     node    = htmlDoc.DocumentNode.SelectSingleNode("//div[@id='product_info']");

            if (node == null)
            {
                return(new ResponseModel
                {
                    status = 404,
                    statusText = "failure",
                });
            }
            var name_node = node.SelectSingleNode("//div[@class='name_info']");
            var name_info = name_node.SelectSingleNode("//h1");

            if (name_info != null)
            {
                book.name = name_info.Attributes["title"].Value;
            }

            var ddzy_info = name_node.SelectSingleNode("//img[@class='icon_name']");

            if (ddzy_info != null)
            {
                book.ddzy = true;
            }
            else
            {
                book.ddzy = false;
            }
            var author_info = node.SelectSingleNode("//span[@id='author']");

            if (author_info != null)
            {
                book.author = author_info.InnerText.Replace("作者:", "");
            }
            var publisher_info = node.SelectSingleNode("//a[@dd_name='出版社']");

            if (publisher_info != null)
            {
                book.publisher = publisher_info.InnerText;
            }

            var price_info = node.SelectSingleNode("//div[@id='original-price']");

            if (price_info != null)
            {
                book.price = float.Parse(price_info.InnerText.Replace("&yen;", ""));
            }
            return(new ResponseModel
            {
                status = 200,
                statusText = "success",
                data = book
            });
        }