Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            // 3.系統在Action【Home/Index】讀取首頁行銷圖示。
            List <HomeImageViewModel> lHIMV = await IMR.GetHomeImageList(0, 1000);

            // 4.系統在Action【Home/Index】讀取youtube影片網址。
            YoutubeVideoViewModel YVVM = await IPR.GetYoutubeVideoList();

            // 5.系統在Action【Home/Index】讀取最新商品清單。
            List <ProductListViewModel> lPLVM = await IPRR.GetNewProductList(6);

            // 6.系統傳回View【Home/Index】,並回傳new HomeViewModel { HomeImage=3讀取值, YoutubeVideo=4讀取值, NewProduct=5讀取值}。
            ViewBag.MemberMobile = HttpContext.Session.GetString("MemberMobile");
            if (HttpContext.Session.GetInt32("MemberLevelId") != null)
            {
                ViewBag.MemberLevelId = HttpContext.Session.GetInt32("MemberLevelId");
            }
            else
            {
                ViewBag.MemberLevelId = -1;
            }
            ViewBag.NickName = HttpContext.Session.GetString("NickName");

            return(View(new HomeViewModel {
                HomeImage = lHIMV, YoutubeVideo = YVVM, NewProduct = lPLVM
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> Index()
        {
            // 4-1.系統讀取發展獎金設定。
            YoutubeVideoViewModel lpvm = await IAR.GetYoutubeVideoList();

            // 5.系統回傳View【YoutubeVideo/Index】,並傳回4-1讀取值。
            return(View(lpvm));
        }
Beispiel #3
0
        public async Task <YoutubeVideoViewModel> GetYoutubeVideoList()
        {
            YoutubeVideoViewModel ret = null;

            try
            {
                using (SqlConnection con = new SqlConnection(constr))
                {
                    var p = new DynamicParameters();
                    p.Add("@r", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
                    await con.OpenAsync();

                    IEnumerable <YoutubeVideoViewModel> tmp = await con.QueryAsync <YoutubeVideoViewModel>("sp_GetYoutubeVideoList", p, commandType : CommandType.StoredProcedure);

                    ret = tmp.FirstOrDefault <YoutubeVideoViewModel>();
                }
            }
            catch (Exception)
            {
                ret = null;
            }
            return(ret);
        }