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)); }
/// <summary> /// [前台]取得最新消息列表 /// </summary> /// <param name="filterModel"></param> /// <returns></returns> public List <NewsFrontEndDataModel> GetNewsListFrontEnd(int dataCount) { List <NewsFrontEndDataModel> data; try { data = DB.WBNEWS.Select(s => new NewsFrontEndDataModel() { ID = s.ID, SortIndex = s.SR_SQ, Title = s.NEWS_TITLE, PartContent = s.NEWS_CONTENT, PublishDateStr = s.PUB_DT, DisplayForFront = (bool)s.DIS_FRONT_ST, DisplayForHomePage = (bool)s.DIS_HOME_ST, }) .ToList(); //篩選+排序 if (dataCount > 0) { data = data .Where(s => s.DisplayForHomePage) .OrderByDescending(o => o.SortIndex) .ThenByDescending(o => o.PublishDateStr) .Take(dataCount) .ToList(); } else { data = data .Where(s => s.DisplayForFront) .OrderByDescending(o => o.SortIndex) .ThenByDescending(o => o.PublishDateStr) .ToList(); } foreach (var d in data) { //取圖檔 ImgModule imgModule = new ImgModule(); d.ImagesData = imgModule.GetImages(d.ID, "News", "S").FirstOrDefault(); } } catch (Exception ex) { throw ex; } return(data); }
public ActionResult NewsEdit(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images) { string langCode = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode; Language language = PublicMethodRepository.GetLanguageEnumByCode(langCode); int? ID = Convert.ToInt32(form["newsID"]); ListModuleService module = ListFactoryService.Create(Enums.ListMethodType.NEWS); int identityId = module.DoSaveData(form, language, ID, image, images); NewsDetailsDataModel model = (module.DoGetDetailsByID((int)identityId) as NewsDetailsDataModel); //取圖檔 ImgModule imgModule = new ImgModule(); model.ImagesData = imgModule.GetImages(model.ID, "News", "S").FirstOrDefault(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("NewsEdit", "_SysAdm", new { ID = identityId }); return(Json(new { Url = redirectUrl })); }
public ActionResult NewsEdit(int?ID) { if (!ID.HasValue) { return(RedirectToAction("News")); } ListModuleService module = ListFactoryService.Create(Enums.ListMethodType.NEWS); NewsDetailsDataModel model = (module.DoGetDetailsByID((int)ID) as NewsDetailsDataModel); if (model == null) { return(RedirectToAction("Login", "SignIn")); } //取圖檔 ImgModule imgModule = new ImgModule(); model.ImagesData = imgModule.GetImages(model.ID, "News", "S").FirstOrDefault(); return(View(model)); }
/// <summary> /// [前台]取得最新消息列表 /// </summary> /// <param name="filterModel"></param> /// <returns></returns> public List <ProductFrontEndDataModel> GetProductListFrontEnd() { List <ProductFrontEndDataModel> data; try { data = DB.WBPRODUCT.Select(s => new ProductFrontEndDataModel() { ID = s.ID, ProductName = s.PRD_NM, ProductKindID = s.MAP_PRODUCT_TP_ID, Sort = s.SR_SQ, ProductType = s.PRD_TP, ProductFeatures = s.PRD_FEAT.Replace("\r\n", "<br>"), ProductMaterial = s.PRD_MT, ProductSpecification = s.PRD_SPE, Content = s.PRD_CONTENT, DisplayForFrontEnd = (bool)s.DIS_FRONT_ST, }) .ToList(); //篩選+排序 data = data .Where(s => s.DisplayForFrontEnd) .OrderByDescending(o => o.Sort) .ToList(); foreach (var d in data) { var kind = this.DB.WBPRODUCTTYPE.Where(o => o.ID == d.ProductKindID).FirstOrDefault(); d.ProductKindName = kind == null ? "" : kind.PRD_TP_NM; //取圖檔 ImgModule imgModule = new ImgModule(); d.ImagesData = imgModule.GetImages(d.ID, "Product", "S").FirstOrDefault(); d.OtherImagesData = imgModule.GetImages(d.ID, "Product", "M"); } } catch (Exception ex) { throw ex; } return(data); }
public ActionResult WorksDataEdit(int?ID) { if (!ID.HasValue) { return(RedirectToAction("WorksList")); } ListModuleService module = ListFactoryService.Create(ListMethodType.WORKS); WorksDetailsDataModel model = (module.DoGetDetailsByID((int)ID) as WorksDetailsDataModel); if (model == null) { return(RedirectToAction("Login", "SignIn")); } //取圖檔 ImgModule imgModule = new ImgModule(); model.ImagesData = imgModule.GetImages(model.ID, "Works", "S").FirstOrDefault(); model.OtherImagesData = imgModule.GetImages(model.ID, "Works", "M"); return(View(model)); }
public JsonResult DeleteImg(int imgID) { bool success = true; string messages = string.Empty; JsonResult resultJson = new JsonResult(); ImgModule imgModule = new ImgModule(); try { imgModule.DeleteImg(imgID); } catch (Exception ex) { messages = string.Format("圖片刪除失敗 :{0}", ex.Message); resultJson = Json(new { success = success, messages = messages }); return(resultJson); } resultJson = Json(new { success = success, messages = "success" }); return(resultJson); }
/// <summary> /// [前台]取得最新消息列表 /// </summary> /// <param name="filterModel"></param> /// <returns></returns> public List <WorksFrontEndDataModel> GetWorksListFrontEnd() { List <WorksFrontEndDataModel> data; try { data = DB.WBWORKS.Select(s => new WorksFrontEndDataModel() { ID = s.ID, WorksPulishDateStr = s.PUB_DT, WorksTitle = s.WKS_TITLE, Sort = s.SR_SQ, Content = s.WKS_CONTENT, DisplayForFrontEnd = (bool)s.DIS_FRONT_ST }) .ToList(); //篩選+排序 data = data .Where(s => s.DisplayForFrontEnd) .OrderByDescending(o => o.Sort) .ToList(); foreach (var d in data) { //取圖檔 ImgModule imgModule = new ImgModule(); d.ImagesData = imgModule.GetImages(d.ID, "Works", "S").FirstOrDefault(); d.OtherImagesData = imgModule.GetImages(d.ID, "Works", "M"); } } catch (Exception ex) { throw ex; } return(data); }
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 })); }
///// <summary> ///// ///// </summary> ///// <param name="Request"></param> ///// <param name="actionName"></param> ///// <param name="path"></param> //public void SaveImagesToDB(int ID, HttpRequestBase Request, string actionName, string path) //{ // List<ImgUploadModel> imgList = new List<ImgUploadModel>(); // for (int i = 0; i < Request.Files.Count; i++) // { // var file = Request.Files[i]; // //建立DB存圖模型 // imgList.Add(new ImgUploadModel() // { // ActionName = actionName, // FileName = file.FileName, // //Mode = "O", // FilePath = path + file.FileName, // FileUrl = PublicMethodRepository.WebDomain + "/Content/Upload/images/" + file.FileName // }); // }; // ImgModule imgModule = new ImgModule(); // //imgModule.SaveImgs(ID, imgList); //} #region 儲存處理函式 /// <summary> /// 寫Log查看表單post的結果 /// </summary> /// <param name="vm"></param> public void SaveImagesToDB(ImagesModel vm) { ImgModule imgModule = new ImgModule(); imgModule.SaveImgs(vm); }