diff --git a/OpenAuth.App/ModuleElementManagerApp.cs b/OpenAuth.App/ModuleElementManagerApp.cs
new file mode 100644
index 00000000..3352abc7
--- /dev/null
+++ b/OpenAuth.App/ModuleElementManagerApp.cs
@@ -0,0 +1,53 @@
+// ***********************************************************************
+// Assembly : OpenAuth.App
+// Author : Yubao Li
+// Created : 12-02-2015
+//
+// Last Modified By : Yubao Li
+// Last Modified On : 12-02-2015
+// ***********************************************************************
+//
+// Copyright (c) . All rights reserved.
+//
+// 模块元素
+// ***********************************************************************
+
+using System.Collections.Generic;
+using OpenAuth.Domain;
+using OpenAuth.Domain.Interface;
+
+namespace OpenAuth.App
+{
+ public class ModuleElementManagerApp
+ {
+ private readonly IRepository _repository;
+
+ public ModuleElementManagerApp(IRepository repository)
+ {
+ _repository = repository;
+ }
+
+ public void AddOrUpdate(ModuleElement model)
+ {
+ if (model.Id == 0)
+ {
+ _repository.Add(model);
+ }
+ else
+ {
+ _repository.Update(model);
+ }
+ }
+
+ public IEnumerable LoadByModuleId(int id)
+ {
+ var modules = _repository.Find(u => u.ModuleId == id);
+ return modules;
+ }
+
+ public void Delete(int id)
+ {
+ _repository.Delete(u =>u.Id ==id);
+ }
+ }
+}
diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj
index a68b7dfd..bb908b5b 100644
--- a/OpenAuth.App/OpenAuth.App.csproj
+++ b/OpenAuth.App/OpenAuth.App.csproj
@@ -44,6 +44,7 @@
+
diff --git a/OpenAuth.Mvc/AutofacExt.cs b/OpenAuth.Mvc/AutofacExt.cs
index 40d4991e..0b74e57d 100644
--- a/OpenAuth.Mvc/AutofacExt.cs
+++ b/OpenAuth.Mvc/AutofacExt.cs
@@ -18,6 +18,8 @@ using Autofac.Integration.Mvc;
using OpenAuth.App;
using System.Reflection;
using System.Web.Mvc;
+using OpenAuth.Domain.Interface;
+using OpenAuth.Repository;
namespace OpenAuth.Mvc
{
@@ -27,12 +29,20 @@ namespace OpenAuth.Mvc
{
var builder = new ContainerBuilder();
+ //ע
+ builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>));
+
+ //Ӧòע
builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
builder.RegisterType();
builder.RegisterType();
builder.RegisterType();
builder.RegisterType();
builder.RegisterType();
+ builder.RegisterType();
+
+
+
// Register your MVC controllers.
builder.RegisterControllers(typeof(MvcApplication).Assembly);
diff --git a/OpenAuth.Mvc/Controllers/BaseController.cs b/OpenAuth.Mvc/Controllers/BaseController.cs
index e1b87e98..851c59e3 100644
--- a/OpenAuth.Mvc/Controllers/BaseController.cs
+++ b/OpenAuth.Mvc/Controllers/BaseController.cs
@@ -30,7 +30,7 @@ namespace OpenAuth.Mvc.Controllers
var loginUser = SessionHelper.GetSessionUser();
if (loginUser == null)
{
- Response.Redirect("/Login/Index");
+ filterContext.Result = new RedirectResult("/Login/Index");
return;
}
@@ -43,7 +43,7 @@ namespace OpenAuth.Mvc.Controllers
&& !url.Contains("Git")
&& !loginUser.Modules.Any(u => url.Contains(u.Url)))
{
- Response.Redirect("/Error/NoAccess");
+ filterContext.Result = new RedirectResult("/Login/Index");
return;
}
}
diff --git a/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs b/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
new file mode 100644
index 00000000..375dde94
--- /dev/null
+++ b/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
@@ -0,0 +1,69 @@
+// ***********************************************************************
+// Assembly : OpenAuth.Mvc
+// Author : Yubao Li
+// Created : 12-02-2015
+//
+// Last Modified By : Yubao Li
+// Last Modified On : 12-02-2015
+// ***********************************************************************
+//
+// Copyright (c) . All rights reserved.
+//
+// 模块元素管理,无需权限控制
+// ***********************************************************************
+
+using System;
+using System.Web.Mvc;
+using Infrastructure;
+using OpenAuth.App;
+using OpenAuth.Domain;
+using OpenAuth.Mvc.Models;
+
+namespace OpenAuth.Mvc.Controllers
+{
+ public class ModuleElementManagerController : Controller
+ {
+ private readonly BjuiResponse _bjuiResponse = new BjuiResponse();
+ private ModuleElementManagerApp _app;
+
+ public ModuleElementManagerController()
+ {
+ _app = (ModuleElementManagerApp) DependencyResolver.Current.GetService(typeof (ModuleElementManagerApp));
+ }
+
+ public ActionResult Index(int id = 0)
+ {
+ ViewBag.ModuleId = id;
+ return View(_app.LoadByModuleId(id));
+ }
+
+ [HttpPost]
+ public string AddOrEditButton(ModuleElement button)
+ {
+ try
+ {
+ _app.AddOrUpdate(button);
+ }
+ catch (Exception e)
+ {
+ _bjuiResponse.statusCode = "300";
+ _bjuiResponse.message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(_bjuiResponse);
+ }
+
+ public string DelButton(int id)
+ {
+ try
+ {
+ _app.Delete(id);
+ }
+ catch (Exception e)
+ {
+ _bjuiResponse.statusCode = "300";
+ _bjuiResponse.message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(_bjuiResponse);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenAuth.Mvc/Controllers/ModuleManagerController.cs b/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
index f913dbea..090a0709 100644
--- a/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
@@ -122,7 +122,7 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(BjuiResponse);
}
- #region 命令操作
+ #region 添加编辑模块
public ActionResult Add(int id = 0)
{
return View(_app.Find(id));
@@ -162,5 +162,6 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(BjuiResponse);
}
#endregion
+
}
}
\ No newline at end of file
diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj
index 074fb901..f0f4014e 100644
--- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj
+++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj
@@ -128,6 +128,7 @@
+
@@ -622,6 +623,7 @@
+
diff --git a/OpenAuth.Mvc/Views/Home/Index.cshtml b/OpenAuth.Mvc/Views/Home/Index.cshtml
index 7711b262..3f1dab32 100644
--- a/OpenAuth.Mvc/Views/Home/Index.cshtml
+++ b/OpenAuth.Mvc/Views/Home/Index.cshtml
@@ -171,7 +171,8 @@
我的账户
diff --git a/OpenAuth.Mvc/Views/Home/Main.cshtml b/OpenAuth.Mvc/Views/Home/Main.cshtml
index 05e6782c..b03b5d99 100644
--- a/OpenAuth.Mvc/Views/Home/Main.cshtml
+++ b/OpenAuth.Mvc/Views/Home/Main.cshtml
@@ -9,18 +9,17 @@