123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using CP.Model;
- using Newtonsoft.Json;
- using NIU.Core;
- using NIU.Core.Log;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CP.Admin.Controllers
- {
- public class CzLinkController : AdminBaseController
- {
- // GET: CzLink
- public ActionResult Index()
- {
- return View();
- }
- public ActionResult Edit(long? id)
- {
- if (id == null)
- {
- return View(new CzLink());
- }
- else
- {
- var info = CzLinkData.GetById(long.Parse(id.ToString()));
- return View(info);
- }
- //return View(new CzLink());
- }
- /// <summary>
- /// 编辑
- ///// </summary>
- //[HttpGet]
- //public ActionResult Edit(long? id)
- //{
- // var info = AreaData.GetById(id);
- // return View(info);
- //}
- /// <summary>
- /// 获取所有的链接
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public JsonResult GetList(int page, int rows)
- {
- var czList = CzLinkData.GetPager(page, rows);
- var easyUIPages = new Dictionary<string, object>();
- easyUIPages.Add("total", czList.TotalItems);
- easyUIPages.Add("rows", czList.Items);
- return Json(easyUIPages, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 保存
- /// </summary>
- [HttpPost, ValidateAntiForgeryToken]
- public JsonResult Edit(CzLink model)
- {
- var apiResult = new APIResult();
- try
- {
- CzLinkData.AddOrUpdate(model);
- }
- catch (Exception ex)
- {
- apiResult.Ret = -1;
- apiResult.Msg = ex.Message;
- if (!(ex is OperationExceptionFacade))
- LogFactory.GetLogger().Log(LogLevel.Error, ex);
- }
- return Json(apiResult);
- }
- /// <summary>
- /// 删除
- /// </summary>
- public ActionResult Delete(int id)
- {
- var apiResult = new APIResult();
- try
- {
- CzLinkData.Delete(id);
- }
- catch (Exception ex)
- {
- apiResult.Ret = -1;
- apiResult.Msg = ex.Message;
- if (!(ex is OperationExceptionFacade))
- LogFactory.GetLogger().Log(LogLevel.Error, ex);
- }
- return Json(apiResult);
- }
- }
- }
|