Ejemplo n.º 1
0
        public JsonResult SaveSection(int sid, string sname, string imgUrl, string AllUserID, string tags, string desc)
        {
            var admins = AllUserID.GetArray();
            //if (admins.Length == 0)
            //{
            //    return Json(new { result = 0, msg = "没有指定版主" }, JsonRequestBehavior.DenyGet);
            //}
            MainSection section;

            if (sid == 0)
            {
                section          = new MainSection();
                section.TenantId = CurrentTenant.TenantId;
            }
            else
            {
                section = _bbsService.GetMainSectionById(sid);
                if (section == null || section.TenantId != CurrentTenant.TenantId)
                {
                    return(Json(new { result = 0, msg = "没有找到要修改的版块" }, JsonRequestBehavior.DenyGet));
                }
            }
            section.SectionName = sname;
            if (Request.Files["frontImg"] != null && Request.Files["frontImg"].ContentLength > 0)
            {
                //Request.Files["frontImg"] .SaveAs("");
                section.FrontImage = SaveFile(Request.Files["frontImg"]);
            }
            else if (!string.IsNullOrEmpty(imgUrl))
            {
                section.FrontImage = imgUrl;
            }
            section.Tags = tags;
            section.SectionDescription = desc;
            if (sid == 0)
            {
                _bbsService.AddMainSection(section);
            }
            else
            {
                _bbsService.UpdateSection(section);
            }
            if (admins.Length > 0)
            {
                _bbsService.ClearSectionAdmins(section.SectionId);
                _bbsService.AddSectionAdmins(admins, section.SectionId);
            }
            return(Json(new { result = 1, msg = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.DenyGet));
        }