using Bootstrap.Security;
using Bootstrap.Security.DataAccess;
using Longbow.Data;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.DataAccess
{
///
///
///
public class Menu : BootstrapMenu
{
///
/// 删除菜单信息
///
///
public virtual bool Delete(IEnumerable value)
{
if (!value.Any()) return true;
var ret = false;
var db = DbManager.Create();
try
{
var ids = string.Join(",", value);
db.BeginTransaction();
db.Execute($"delete from NavigationRole where NavigationID in ({ids})");
db.Execute($"delete from Navigations where ID in ({ids})");
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
{
db.AbortTransaction();
throw ex;
}
return ret;
}
///
/// 保存新建/更新的菜单信息
///
///
///
public virtual bool Save(BootstrapMenu p)
{
if (string.IsNullOrEmpty(p.Name)) throw new ArgumentNullException(nameof(p.Name));
if (p.Name.Length > 50) p.Name = p.Name.Substring(0, 50);
if (p.Icon != null && p.Icon.Length > 50) p.Icon = p.Icon.Substring(0, 50);
if (p.Url != null && p.Url.Length > 4000) p.Url = p.Url.Substring(0, 4000);
DbManager.Create().Save(p);
return true;
}
///
/// 查询某个角色所配置的菜单
///
///
///
public virtual IEnumerable