Esempio n. 1
0
        public ActionResult Index(int Page = 1)
        {
            //宣告一個新頁面模型
            ItemView Data = new ItemView();

            //新增頁面模型中的分頁
            Data.Paging = new ForPaging(Page);
            //從Service中取得頁面所需陣列資料
            Data.IdList    = itemService.GetIdList(Data.Paging);
            Data.ItemBlock = new List <ItemDetailView>();
            foreach (var Id in Data.IdList)
            {
                //宣告一個新陣列內物件
                ItemDetailView newBlock = new ItemDetailView();
                //藉由Service取得商品資料
                newBlock.Data = itemService.GetDataById(Id);
                //取得Session內購物車資料
                string Cart = (HttpContext.Session["Cart"] != null)
                    ? HttpContext.Session["Cart"].ToString() : null;
                //藉由Service確認是否於購物車中
                newBlock.InCart = cartService.CheckInCart(Cart, Id);
                Data.ItemBlock.Add(newBlock);
            }
            //將頁面資料傳入View中
            return(View(Data));
        }
Esempio n. 2
0
        private void LihatItemOnClick(object sender, RoutedEventArgs e)
        {
            ItemDetailView itemDetailView = new ItemDetailView();

            //Berguna supaya tidak bisa di alt tab
            itemDetailView.Owner = Window.GetWindow((Window)PresentationSource.FromVisual(this).RootVisual);
            itemDetailView.initDetail(item: this.item);
            itemDetailView.ShowDialog();
        }
Esempio n. 3
0
 private ItemDetailView UpdateProductStock(ItemDetailView product, int existQuantity, int newQuantity)
 {
     if (existQuantity > newQuantity)
     {
         product.Quantity += (existQuantity - newQuantity);
     }
     else if (newQuantity > existQuantity)
     {
         product.Quantity -= (newQuantity - existQuantity);
     }
     return(product);
 }
Esempio n. 4
0
        public void NavigateToItemDetail(Guid windowId, int id, int userId, NavigationMode navigationMode = NavigationMode.SHOW)
        {
            ItemDetailView view = new ItemDetailView()
            {
                DataContext = new ItemDetailViewModel(id, userId)
                {
                    StockNumber = id
                }
            };

            Show(windowId, view, navigationMode);
        }
Esempio n. 5
0
        //商品列表中每一個商品區塊Action
        public ActionResult ItemBlock(int Id)
        {
            //宣告一個新頁面模型
            ItemDetailView ViewData = new ItemDetailView();

            //藉由Service取得商品資料
            ViewData.Data = itemService.GetDataById(Id);
            //取得Session內購物車資料
            string Cart = (HttpContext.Session["Cart"] != null)
                ? HttpContext.Session["Cart"].ToString() : null;

            //藉由Service確認是否於購物車中
            ViewData.InCart = cartService.CheckInCart(Cart, Id);
            //將資料傳入View中
            return(PartialView(ViewData));
        }