public ApiResult <bool> AddRole(Role model) { var rst = new ApiResult <bool>() { Message = "添加失败" }; try { using Trans t = new Trans(); if (roleDal.Add(model, t).Result) { //插入角色菜单关联表 model.menu_ids?.ForEach(c => authorityDal.Add(new Authority() { menu_id = c, role_id = model.role_id }, t)); t.Commit(); rst.Result = true; rst.Message = "添加成功"; } } catch (Exception ex) { rst.Message = $"添加失败:{ex.InnerException ?? ex}"; LogHelper.Error($"{ex.InnerException ?? ex}"); } return(rst); }
public ApiResult <bool> Add(Authority model) { using (authorityDal) { return(authorityDal.Add(model)); } }