コード例 #1
0
        public QueryStartProductResponse QueryStartProduct([FromBody] QueryStartProductRequest request)
        {
            QueryStartProductResponse response = new QueryStartProductResponse();
            List <StartProdect>       list     = _context.StartProdects.OrderBy(a => a.PKID).Skip((request.PageIndex - 1) * request.PageNum).Take(request.PageNum).ToList();

            foreach (var item in list)
            {
                response.StartProductList.Add(new StartProductModel
                {
                    PKID      = item.PKID,
                    StartName = item.StartName,
                    Describe  = item.Describe,
                    Price     = item.Price,
                    StartImg  = item.StartImg,
                    LinkPage  = item.LinkPage
                });
            }
            return(response);
        }
コード例 #2
0
        public async Task <IActionResult> Index()
        {
            ViewBag.UserName = string.Empty;
            if (Request.Cookies["MIUserName"] != null)
            {
                if (Request.Cookies.TryGetValue("MIUserName", out string userName))
                {
                    ViewBag.UserName = userName;
                }
            }

            QueryStartProductRequest request = new QueryStartProductRequest {
                PageIndex = 1, PageNum = 5
            };
            QueryStartProductResponse response = null;

            try
            {
                response = await pictureService.QueryStartProduct(request);

                if (response.Successful)
                {
                    //轮播图
                    var querySlideImgResponse = await pictureService.QuerySlideImg();

                    ViewData["SlideImg"] = querySlideImgResponse.SlideImgList;

                    //查询智能硬件表数据
                    var queryHadrWareResponse = await pictureService.QueryHadrWare();

                    ViewData["HradWare"] = queryHadrWareResponse.HadrWareList;
                    return(View(response.StartProductList));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }

            return(View());
        }