Esempio n. 1
0
        /// <summary>
        /// 产品详情页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> Details(int id)
        {
            if (id == 0)
            {
                return(View("Error"));
            }
            else
            {
                if (string.IsNullOrEmpty(GetCookies("number")))
                {
                    SetCookies("number", id.ToString());
                    var numberadd = _homeService.AddNumber(id);
                }
                else
                {
                    var ids = GetCookies("number").Split(",");
                    if (Array.IndexOf(ids, id.ToString()) == -1)
                    {
                        SetCookies("number", GetCookies("number") + "," + id.ToString());
                        var numberadd = _homeService.AddNumber(id);
                    }
                }
                var product = await _homeService.GetOneProduct(id);

                var ViewModel = new DetailsViewModel
                {
                    common      = await _homeService.GetCommon(),
                    product     = product,
                    prevproduct = await _homeService.GetPrevProduct(id),
                    nextproduct = await _homeService.GetNextProduct(id)
                };
                ViewData["description"] = RemoveHTML(product.content);
                ViewData["keywords"]    = RemoveHTML(product.content);
                return(View(ViewModel));
            }
        }