OpenAuth.Net/OpenAuth.Mvc/Controllers/CategoryManagerController.cs

75 lines
1.8 KiB
C#
Raw Normal View History


2015-12-15 23:04:20 +08:00
using System;
using System.Web.Mvc;
using Infrastructure;
using OpenAuth.App;
using OpenAuth.Domain;
using OpenAuth.Mvc.Models;
2015-12-15 23:04:20 +08:00
namespace OpenAuth.Mvc.Controllers
{
public class CategoryManagerController : BaseController
{
private CategoryManagerApp _app;
public CategoryManagerController()
{
_app = AutofacExt.GetFromFac<CategoryManagerApp>();
2015-12-15 23:04:20 +08:00
}
//
// GET: /UserManager/
[Authenticate]
2015-12-15 23:04:20 +08:00
public ActionResult Index()
{
return View();
}
/// <summary>
/// 加载分类下面的所有分类
/// </summary>
2016-10-17 11:43:56 +08:00
public string Load(Guid parentId, int page = 1, int rows = 30)
{
2016-10-17 11:43:56 +08:00
return JsonHelper.Instance.Serialize(_app.Load(parentId, page, rows));
}
public string LoadForTree()
{
return JsonHelper.Instance.Serialize(_app.LoadAll());
}
2015-12-15 23:04:20 +08:00
//添加或修改Category
[HttpPost]
public string Add(Category model)
{
try
{
_app.AddOrUpdate(model);
}
catch (Exception ex)
{
2016-10-14 11:22:16 +08:00
Result.Status = false;
Result.Message = ex.Message;
2015-12-15 23:04:20 +08:00
}
2016-10-14 11:22:16 +08:00
return JsonHelper.Instance.Serialize(Result);
2015-12-15 23:04:20 +08:00
}
2016-10-14 17:03:18 +08:00
[HttpPost]
public string Delete(Guid[] ids)
2015-12-15 23:04:20 +08:00
{
try
{
2016-10-14 17:03:18 +08:00
_app.Delete(ids);
2015-12-15 23:04:20 +08:00
}
catch (Exception e)
{
2016-10-14 11:22:16 +08:00
Result.Status = false;
Result.Message = e.Message;
2015-12-15 23:04:20 +08:00
}
2016-10-14 11:22:16 +08:00
return JsonHelper.Instance.Serialize(Result);
2015-12-15 23:04:20 +08:00
}
}
}