2015-11-13 21:33:53 +08:00
|
|
|
|
using Infrastructure;
|
|
|
|
|
using OpenAuth.App;
|
|
|
|
|
using OpenAuth.Domain;
|
|
|
|
|
using System;
|
2015-10-26 21:58:12 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.Mvc;
|
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
|
|
|
|
|
|
|
|
|
public ActionResult Add()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加组织提交
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public string Add(UserView org)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int[] orgIds = org.OrganizationIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
|
|
|
|
_app.Add(org, orgIds);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BjuiResponse.statusCode = "300";
|
|
|
|
|
BjuiResponse.message = ex.Message;
|
|
|
|
|
}
|
|
|
|
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Edit(string json)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var org = JsonHelper.Instance.Deserialize<User>(json);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BjuiResponse.statusCode = "300";
|
|
|
|
|
BjuiResponse.message = ex.Message;
|
|
|
|
|
}
|
|
|
|
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载组织下面的所有用户
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Load(int orgId)
|
|
|
|
|
{
|
|
|
|
|
return JsonHelper.Instance.Serialize(_app.Load(orgId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|