Esempio n. 1
0
        //在 Create Page ,dropdownlist 使用
        //It is necessary to set string type in parameter or else you will get Internal Server error 500.
        public JsonResult GetProductCategories(string typeSelected)
        {
            ProductViewModels mView = new ProductViewModels();

            mView.Categories = ProductEnumLists.GetCategories(typeSelected);
            return(Json(new { mView.Categories }));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public Action UploadVideo(IEnumerable<HttpPostedFileBase>files)
        //{
        //    if (files.First()!=null)
        //    {
        //        foreach (var file in files)
        //        {
        //            string SourceFileName = Path.GetFileName(file.FileName);

        //        }
        //    }
        //    return View();
        //}


        // GET: Product/Create
        public ActionResult Create()
        {
            ProductViewModels vModel = new ProductViewModels();

            //Kinds dropdownlist
            vModel.Kinds = ProductEnumLists.GetInitKinds();
            //Category dropdownlist
            vModel.Categories = ProductEnumLists.GetInitCategories();

            //取得目前登入使用者Id
            var UserId = HttpContext.User.Identity.GetUserId();

            vModel.MId = UserId;

            return(View(vModel));
        }