后台内容管理

This commit is contained in:
hogan
2019-01-24 00:14:06 +08:00
parent e9890b771a
commit a9afd0d23d
5 changed files with 96 additions and 44 deletions

View File

@ -29,7 +29,6 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
this.DocumentContentDAL = new DocumentContentDAL();
}
public IActionResult Index()
{
DocumentContent model = new DocumentContent();
@ -87,7 +86,8 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
DocumentContent model = new DocumentContent();
if (!string.IsNullOrEmpty(id))
{
model = DocumentContentDAL.GetByOne(w => w.ID == 1);
int _id = Convert.ToInt32(id);
model = DocumentContentDAL.GetByOne(w => w.ID == _id);
}
return View(model);
}
@ -108,6 +108,24 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
return Json(resdata);
}
// POST: Documents/Create
[HttpPost]
//[ValidateAntiForgeryToken]
public ActionResult DocContentUpdate([FromBody]DocumentContent model)
{
var resdata = AutoException.Excute<bool>((result) =>
{
model.UpdateBy = "admin";
model.UpdateDt = DateTime.Now;
result.Data = DocumentContentDAL.Update(model);
if (result.Data == false)
{
throw new Exception("数据新增异常JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
}
}, false);
return Json(resdata);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult DocContentDelete(int id, IFormCollection collection)