调整数据库菜单表结构,可以动态加载按钮,注意更新数据库结构并重新初始化数据库

This commit is contained in:
yubaolee
2015-12-05 16:07:53 +08:00
parent 135723f563
commit af5e04d62f
16 changed files with 805 additions and 1090 deletions

View File

@@ -1,69 +1,72 @@
// ***********************************************************************
// Assembly : OpenAuth.Mvc
// Author : Yubao Li
// Created : 12-02-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 12-02-2015
// ***********************************************************************
// <copyright file="ModuleElementManagerController.cs" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>模块元素管理,无需权限控制</summary>
// ***********************************************************************
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);
}
}
// ***********************************************************************
// Assembly : OpenAuth.Mvc
// Author : Yubao Li
// Created : 12-02-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 12-02-2015
// ***********************************************************************
// <copyright file="ModuleElementManagerController.cs" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>模块元素管理,无需权限控制</summary>
// ***********************************************************************
using System;
using System.Data.Entity.Validation;
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
{
var newbtn = new ModuleElement();
button.CopyTo(newbtn);
_app.AddOrUpdate(newbtn);
}
catch (DbEntityValidationException 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);
}
}
}