Beispiel #1
0
        // GET: Product/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IEnumerable <ProductViewModels> vModelList;
            ProductEntity pe = new ProductEntity();

            vModelList = pe.QueryByProductId(id.ToString());
            if (vModelList == null)
            {
                return(HttpNotFound());
            }

            ProductViewModels vModel = vModelList.ToList()[0];

            //Kinds dropdownlist
            vModel.Kinds = ProductEnumLists.GetInitKinds();
            //Category dropdownlist
            vModel.Categories = ProductEnumLists.GetCategories(vModel.SelectedKinds.ToString());


            //這邊為了方便起見,先只回傳一筆,理論上應該是要直接回傳單一個 ViewModel
            return(View(vModel));
        }
        public ActionResult View(int?id)
        {
            if (id != null)
            {
                ProductEntity pe    = new ProductEntity();
                var           query = pe.QueryByProductId(id.ToString());
                ViewBag.keyword = query.FirstOrDefault().Categories;

                TFDBLibrary.TakeFiveDBEntities db = new TFDBLibrary.TakeFiveDBEntities();
                string userid = HttpContext.User.Identity.GetUserId();
                if (userid != null)
                {
                    var buyquery = from c in db.buyitemdetailtbl
                                   where c.mid == userid && c.pid == id
                                   select c;

                    if (buyquery.Count() > 0)
                    {
                        ViewBag.Buy = true;
                    }
                    else
                    {
                        ViewBag.Buy = false;
                    }
                }
                else
                {
                    ViewBag.Buy = false;
                }

                return(View(query));
            }

            return(View());
        }
Beispiel #3
0
        public ActionResult ProductDetail(int?id)
        {
            IEnumerable <ProductViewModels> vModelList;
            ProductEntity pe = new ProductEntity();

            vModelList = pe.QueryByProductId(id.ToString());
            if (vModelList == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_ProductDetail", vModelList));
        }
Beispiel #4
0
        // GET: Categories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IEnumerable <ProductViewModels> vModelList;
            ProductEntity pe = new ProductEntity();

            vModelList = pe.QueryByProductId(id.ToString());
            if (vModelList == null)
            {
                return(HttpNotFound());
            }

            //這邊為了方便起見,先只回傳一筆,理論上應該是要直接回傳單一個 ViewModel
            ProductViewModels vModel = vModelList.ToList()[0];

            return(View(vModel));
        }