public IHttpActionResult Delete()
        {
            try
            {
                var request   = new AuthenticatedRequest();
                var siteId    = request.GetPostInt("siteId");
                var specialId = request.GetPostInt("specialId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(siteId,
                                                                     ConfigManager.SitePermissions.Specials))
                {
                    return(Unauthorized());
                }

                var siteInfo    = SiteManager.GetSiteInfo(siteId);
                var specialInfo = SpecialManager.DeleteSpecialInfo(siteInfo, specialId);

                request.AddSiteLog(siteId,
                                   "删除专题",
                                   $"专题名称:{specialInfo.Title}");

                var specialInfoList = DataProvider.SpecialDao.GetSpecialInfoList(siteId);

                return(Ok(new
                {
                    Value = specialInfoList
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            var specialId = AuthRequest.GetQueryInt("specialId");
            var keyword   = AuthRequest.GetQueryString("keyword");

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

            TbKeyword.Text = keyword;

            if (specialId > 0)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["delete"]))
                {
                    var specialInfo = SpecialManager.DeleteSpecialInfo(SiteId, specialId);

                    AuthRequest.AddSiteLog(SiteId,
                                           "删除专题",
                                           $"专题名称:{specialInfo.Title}");

                    SuccessDeleteMessage();
                }
                else if (!string.IsNullOrEmpty(Request.QueryString["download"]))
                {
                    var specialInfo   = SpecialManager.GetSpecialInfo(SiteId, specialId);
                    var directoryPath = SpecialManager.GetSpecialDirectoryPath(SiteInfo, specialInfo.Url);
                    var zipFilePath   = SpecialManager.GetSpecialZipFilePath(directoryPath);
                    PageUtils.Download(Response, zipFilePath, $"{specialInfo.Title}.zip");
                    return;
                }
            }

            RptContents.DataSource = string.IsNullOrEmpty(keyword)
                ? DataProvider.SpecialDao.GetSpecialInfoList(SiteId)
                : DataProvider.SpecialDao.GetSpecialInfoList(SiteId, keyword);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAdd.Attributes.Add("onclick", ModalSpecialAdd.GetOpenWindowString(SiteId));
        }