using PageAdmin.BLL;
using PageAdmin.Utils;
using PageAdmin.Web.Filter;
using System.Web.Mvc;

namespace PageAdmin.Web.Areas.E.Controllers
{
    public class AttachmentsController : Controller
    {


        /// <summary>
        /// 前端根据id和guid删除，加guid避免恶意删除
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        [ValidateAntiForgeryToken]
        [AjaxOnly]
        [HttpPost]
        public JsonResult Delete(FormCollection form)
        { 
            int id = StringHelper.Format<int>(form["id"]);
            string guid = form["guid"];
            TipsInfo tipsInfo = new TipsInfo();
            AttachmentsBLL attachmentDataBLL = new AttachmentsBLL();
            int num = attachmentDataBLL.Delete(id, guid);
            if (num ==0)
            {
                tipsInfo.State = 0;
                tipsInfo.Msg = "删除失败！";
            }
            return Json(tipsInfo);
        }



    }
}