public ActionResult ProductDataEdit(int?ID, bool error = false)
        {
            if (!ID.HasValue)
            {
                return(RedirectToAction("ProductList"));
            }
            ListModuleService       module = ListFactoryService.Create(ListMethodType.PRODUCT);
            ProductDetailsDataModel model  = (module.DoGetDetailsByID((int)ID) as ProductDetailsDataModel);

            if (model == null)
            {
                return(RedirectToAction("Login", "SignIn"));
            }
            //取圖檔
            ImgModule imgModule = new ImgModule();

            model.ImagesData      = imgModule.GetImages(model.ID, "Product", "S").FirstOrDefault();
            model.OtherImagesData = imgModule.GetImages(model.ID, "Product", "M");
            //產品分類下拉選單
            ProductKindModule typeModule = new ProductKindModule();
            SelectList        typeList   = typeModule.CreateProductKindDropList(model.TypeID, false, model.DisplayForFrontEnd);

            ViewBag.TypeList = typeList;
            if (error)
            {
                TempData["ERROR"] = "此分類已被停用,若要顯示前台請先將分類啟用";
            }
            return(View(model));
        }
        public ActionResult ProductsAdd()
        {
            var today = DateTime.UtcNow.AddHours(8).ToString("yyyy\\-MM\\-dd");
            ProductDetailsDataModel defaultModel = new ProductDetailsDataModel();

            defaultModel.Data = new Entities.PRODUCT()
            {
                PUBLISH_DT = today,
                SORT       = 1,
            };
            return(View(defaultModel));
        }
        public override object DoGetDetailsByID(int ID)
        {
            ProductDetailsDataModel data = DB.WBPRODUCT.Select(s => new ProductDetailsDataModel
            {
                ID                   = s.ID,
                ProductName          = s.PRD_NM,
                TypeID               = s.MAP_PRODUCT_TP_ID,
                Sort                 = s.SR_SQ,
                ProductType          = s.PRD_TP,
                ProductFeatures      = s.PRD_FEAT,
                ProductMaterial      = s.PRD_MT,
                ProductSpecification = s.PRD_SPE,
                Content              = s.PRD_CONTENT,
                DisplayForFrontEnd   = (bool)s.DIS_FRONT_ST
            }).Where(w => w.ID == ID).FirstOrDefault();

            return(data);
        }
        public ActionResult ProductsAdd()
        {
            ProductDetailsDataModel defaultModel = new ProductDetailsDataModel();

            defaultModel.Data.BUD_DT            = DateTime.UtcNow.AddHours(8);
            defaultModel.Data.HOME_PAGE_DISPLAY = true;
            using (var db = new REDOXDB())
            {
                if (db.PRODUCT.Count() > 0)
                {
                    defaultModel.Data.SQ = db.PRODUCT.Max(s => s.SQ) + 1;
                }
                else
                {
                    defaultModel.Data.SQ = 1;
                }
            }
            return(View(defaultModel));
        }
Beispiel #5
0
        public override object DoGetDetailsByID(int ID)
        {
            ProductDetailsDataModel result = new ProductDetailsDataModel();
            PRODUCT data = new PRODUCT();

            if (PublicMethodRepository.CurrentMode == SiteMode.FronEnd)
            {
                data = DB.PRODUCT.Where(w => w.ID == ID && !w.DISABLE).FirstOrDefault();
            }
            else if (PublicMethodRepository.CurrentMode == SiteMode.Home)
            {
                data = DB.PRODUCT.Where(w => w.ID == ID && !w.DISABLE && w.HOME_PAGE_DISPLAY).FirstOrDefault();
            }
            else
            {
                data = DB.PRODUCT.Where(w => w.ID == ID).FirstOrDefault();
            }
            PublicMethodRepository.HtmlDecode(data);
            result.Data = data;
            return(result);
        }
        public ActionResult ProductDataEdit(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images)
        {
            string            langCode   = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language          language   = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            int?              ID         = Convert.ToInt32(form["ProductID"]);
            ProductKindModule typeModule = new ProductKindModule();

            #region 判斷狀態是否已被停用 被停用 不得啟用前台顯示
            if (ID.HasValue)
            {
                int chkTypeID = Convert.ToInt16(form["type"]);
                ProductKindDetailsDataModel tModel = (typeModule.DoGetDetailsByID(chkTypeID) as ProductKindDetailsDataModel);
                bool tpStatus  = tModel.Status == "Y" ? true : false;
                bool setStatus = form["fSt"] == null ? false : true;
                if ((!tpStatus) && (setStatus))
                {
                    var redirectErrorUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = ID, error = true });
                    return(Json(new { Url = redirectErrorUrl }));
                }
            }

            #endregion
            ListModuleService module      = ListFactoryService.Create(ListMethodType.PRODUCT);
            int identityId                = module.DoSaveData(form, language, ID, image, images);
            ProductDetailsDataModel model = (module.DoGetDetailsByID((int)identityId) as ProductDetailsDataModel);
            //取圖檔
            ImgModule imgModule = new ImgModule();
            model.ImagesData      = imgModule.GetImages(model.ID, "Product", "S").FirstOrDefault();
            model.OtherImagesData = imgModule.GetImages(model.ID, "Product", "M");
            //產品分類下拉選單
            SelectList typeList = typeModule.CreateProductKindDropList(model.TypeID, false, model.DisplayForFrontEnd);
            ViewBag.TypeList = typeList;

            var redirectUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = identityId });
            return(Json(new { Url = redirectUrl }));
        }