public ActionResult ModifyRoleLink() { if (Profile != null) { var frl = Request <List <sys_func_roles_link> >("inputData"); var rid = RequestInt64("rid"); if (frl.Count > 0) { ModifyRoleFuncLinkCommand command = new ModifyRoleFuncLinkCommand(rid ?? -1, 1); frl.ForEach(f => { if (f.fid != null) { command.FidList.Add(f.fid ?? -1); } }); CommandBus.Instance.Send(command); return(new ActionResult(command.Result.Status, DbInstance.Db.Queryable <sys_func_roles_link>().ToList(), null, command.Result.Msg)); } else { return(new ActionResult(false, null, null, "角色功能列表至少1条!")); } } return(new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!")); }
public void Execute(ModifyRoleFuncLinkCommand command) { Role role = _roleRepository.GetById(command.Id); role.RemoveAllFunc(); command.FidList.ForEach(f => { if (!role.Funcs.Exists(ff => ff.Fid == f)) { role.AddFunc(f); } }); _roleRepository.SaveChange(role); command.Result.Status = true; }