public ActionResult Edit(long SiteID, long MenuID, CategoryModels model)
        {
            if (!string.IsNullOrWhiteSpace(model.Image))
            {
                WorkV3.Models.ResourceImagesModels imgModel = JsonConvert.DeserializeObject <WorkV3.Models.ResourceImagesModels>(model.Image);
                if (imgModel.ID == 0)
                { // 新上傳的圖片
                    HttpPostedFileBase postedFile = Request.Files["fImage"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        model.Image = string.Empty;
                    }
                    else
                    {
                        model.Image = Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, SiteID, MenuID);
                    }
                }
                else
                {
                    model.Image = imgModel.Img;
                }
            }

            if (model.PresetIdentity == (int)PresetIdentity.一般會員)
            {
                model.MemberSession = (int)MemberSession.限制;
            }

            ViewBag.SiteID      = SiteID;
            ViewBag.MenuID      = MenuID;
            ViewBag.UploadVPath = UpdFileInfo.GetVPathByMenuID(SiteID, MenuID);
            CategoryDAO.SetItem(model);
            ViewBag.Exit = true;
            return(View(model));
        }
Example #2
0
        public string GetFirstImg(ArticleSettingModels setting)
        {
            if (CustomIcon && !string.IsNullOrWhiteSpace(Icon))
            {
                ResourceImagesModels img = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(Icon);
                if (!string.IsNullOrWhiteSpace(img?.Img))
                {
                    return(img.Img);
                }
            }

            string paragraphImg = ParagraphDAO.GetFirstImage(ID);

            if (!string.IsNullOrWhiteSpace(paragraphImg))
            {
                return(paragraphImg);
            }

            if (!string.IsNullOrWhiteSpace(setting?.DefaultImg))
            {
                ResourceImagesModels img = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(setting.DefaultImg);
                if (!string.IsNullOrWhiteSpace(img?.Img))
                {
                    return(img.Img);
                }
            }

            return(null);
        }