public object Delete(RoleLeftNavigationModel model) { var role = _roleService.GetRole(model.RoleModel.Id); var leftNavigation = _roleService.GetLeftNavigation(model.LeftNavigationModel.Id); if (role != null && leftNavigation != null) { if (leftNavigation.Parent == null) { var subNavgation = _roleService.GetLeftNavigations().Where(n => n.Parent.Id == leftNavigation.Id).ToArray(); foreach (var item in subNavgation) { role.LeftNavigations.Remove(item); } } role.LeftNavigations.Remove(leftNavigation); if (role.LeftNavigations.Count <= 1) { role.LeftNavigations.Clear(); } try { _roleService.Update(); return Success(); } catch (Exception ex) { return Failed(ex.Message); } } return Failed("找不到人员或者菜单"); }
public object Post(RoleLeftNavigationModel model) { if (model == null || model.LeftNavigationModel == null || model.RoleModel == null) { return Failed("不得为空"); } var role = _roleService.GetRole(model.RoleModel.Id); var leftNavigation = _roleService.GetLeftNavigation(model.LeftNavigationModel.Id); if (role != null && leftNavigation != null) { role.LeftNavigations.Add(leftNavigation); if (leftNavigation.Parent != null) { role.LeftNavigations.Add(leftNavigation.Parent); } try { _roleService.Update(); return Success(); } catch (Exception ex) { return Failed(ex.Message); } } return Failed("找不到人员或者菜单"); }