74 lines
2.7 KiB
C#
74 lines
2.7 KiB
C#
using CRM.Core.BLL.Util;
|
|
using CRM.Core.Model.Entity;
|
|
using CRM.Core.Model.Map;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.Common;
|
|
|
|
namespace CRM.Core.BLL.Base
|
|
{
|
|
public class BAS_ROLEPERMISSION_BL
|
|
{
|
|
|
|
/// <summary>
|
|
/// 修改角色权限
|
|
/// </summary>
|
|
/// <param name="errors"></param>
|
|
/// <param name="role_Permisson"></param>
|
|
/// <returns></returns>
|
|
public bool Update(ref ValidationErrors errors, Bas_Role_Permisson role_Permisson)
|
|
{
|
|
try
|
|
{
|
|
using (zxdContext db = new zxdContext())
|
|
{
|
|
db.BAS_ROLE_PERMISSION.RemoveRange(db.BAS_ROLE_PERMISSION.Where(m => m.RID == role_Permisson.RID));
|
|
if (role_Permisson.PERMISSON != null && role_Permisson.PERMISSON.Count > 0)
|
|
foreach (var item in role_Permisson.PERMISSON)
|
|
{
|
|
BAS_ROLE_PERMISSION model = new BAS_ROLE_PERMISSION()
|
|
{
|
|
RID = role_Permisson.RID,
|
|
RNAME = role_Permisson.RNAME,
|
|
CODE = item.CODE,
|
|
PNAME = item.PNAME,
|
|
TOOLBARAVLUE = item.TOOLBARAVLUE,
|
|
PID = item.PID
|
|
};
|
|
db.BAS_ROLE_PERMISSION.Add(model);
|
|
|
|
}
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取角色权限详细
|
|
/// </summary>
|
|
/// <param name="rid"></param>
|
|
/// <returns></returns>
|
|
public Bas_Role_Permisson GetDetial(int rid)
|
|
{
|
|
using (zxdContext db = new zxdContext())
|
|
{
|
|
var model = db.BAS_ROLE.FirstOrDefault(m => m.ROLEID == rid);
|
|
if (model == null)
|
|
throw new Exception("角色参数错误!");
|
|
var list = db.BAS_ROLE_PERMISSION.Where(m => m.RID == rid).ToList();
|
|
Bas_Role_Permisson my = new Bas_Role_Permisson() { RID = rid, RNAME = model.RNAME, PERMISSON = new List<Bas_Role_PermissonArry>() };
|
|
foreach (var item in list)
|
|
{
|
|
my.PERMISSON.Add(new Bas_Role_PermissonArry() { CODE = item.CODE, PNAME = item.PNAME, TOOLBARAVLUE = item.TOOLBARAVLUE, PID = item.PID });
|
|
}
|
|
return my;
|
|
}
|
|
}
|
|
}
|
|
}
|