OpenAuth.Net/OpenAuth.Mvc/Controllers/UserManagerController.cs

79 lines
2.0 KiB
C#
Raw Normal View History

2015-11-15 00:13:49 +08:00
using System;
2015-10-26 21:58:12 +08:00
using System.Web.Mvc;
2015-11-15 00:13:49 +08:00
using Infrastructure;
using OpenAuth.App;
2015-11-13 21:33:53 +08:00
using OpenAuth.App.ViewModel;
2015-10-26 21:58:12 +08:00
namespace OpenAuth.Mvc.Controllers
{
2015-11-08 23:19:04 +08:00
public class UserManagerController : BaseController
2015-10-26 21:58:12 +08:00
{
2015-11-13 21:33:53 +08:00
private UserManagerApp _app;
public UserManagerController()
{
_app = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
}
2015-10-26 21:58:12 +08:00
//
// GET: /UserManager/
public ActionResult Index()
{
return View();
}
2015-11-13 21:33:53 +08:00
2015-11-15 00:13:49 +08:00
public ActionResult Add(int id = 0)
2015-11-13 21:33:53 +08:00
{
2015-11-15 00:13:49 +08:00
return View(_app.Find(id));
2015-11-13 21:33:53 +08:00
}
//添加组织提交
[HttpPost]
2015-11-15 00:13:49 +08:00
public string Add(UserView view)
2015-11-13 21:33:53 +08:00
{
try
{
2015-11-15 00:13:49 +08:00
_app.AddOrUpdate(view);
2015-11-13 21:33:53 +08:00
}
catch (Exception ex)
{
BjuiResponse.statusCode = "300";
BjuiResponse.message = ex.Message;
}
return JsonHelper.Instance.Serialize(BjuiResponse);
}
/// <summary>
/// 加载组织下面的所有用户
/// </summary>
2015-11-15 00:13:49 +08:00
public string Load(int orgId, int pageindex = 1, int pagesize = 10)
{
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageindex, pagesize));
}
//获取组织下面用户个数
public int GetCount(int orgId)
2015-11-13 21:33:53 +08:00
{
2015-11-15 00:13:49 +08:00
return _app.GetUserCntInOrg(orgId);
2015-11-13 21:33:53 +08:00
}
public string Delete(string Id)
{
try
{
foreach (var obj in Id.Split(','))
{
_app.Delete(int.Parse(obj));
}
}
catch (Exception e)
{
BjuiResponse.statusCode = "300";
BjuiResponse.message = e.Message;
}
return JsonHelper.Instance.Serialize(BjuiResponse);
}
}
2015-10-26 21:58:12 +08:00
}