public void RoleMenuCopyFromRoleId(Guid fromRoleId, Guid toRoleId) { this._memoryCacheManager.RemoveStartWith(MemoryCacheKey.CURRENT_USER_ROLE_MENU); if (fromRoleId == toRoleId || fromRoleId == Guid.Empty || toRoleId == Guid.Empty) { throw new Exception("Unable to copy Menu's. Please check your entry or get assistance from your administrator."); } var data = RoleMenuGetByRoleId(fromRoleId); Guid userId = this.GetCurrentUserId(); using (TransactionScope ts = new TransactionScope()) { foreach (var rm in data) { var p = new sys_RoleMenu() { roleId = toRoleId, sourceMenuId = rm.menuId, description = rm.description, displayOrder = rm.displayOrder, updatedBy = userId, }; this._repoRoleMenu.Insert(p); this._unitOfWork.Save(); _RoleMenuModelToEntity(userId, toRoleId, rm, p); } ts.Complete(); } }
public static sys_RoleMenu AddChild(this sys_RoleMenu parent, Repository <sys_RoleMenu> repo, Action <List <sys_RoleMenu> > menuList) { var list = new List <sys_RoleMenu>(); menuList(list); foreach (var item in list) { item.parentRoleMenuId = parent.id; repo.Insert(item); } return(parent); }
private void _RoleMenuModelToEntity(Guid userId, Guid roleId, RoleMenuModel model, sys_RoleMenu entity) { if (model.Childs.Any()) { foreach (var item in model.Childs) { var rm = new sys_RoleMenu() { roleId = roleId, sourceMenuId = item.menuId, description = item.description, displayOrder = item.displayOrder, updatedBy = userId, parentRoleMenuId = entity.id, }; this._repoRoleMenu.Insert(rm); this._unitOfWork.Save(); _RoleMenuModelToEntity(userId, roleId, item, rm); } } }
public static sys_RoleMenu AddListReturnValue(this List <sys_RoleMenu> the, sys_RoleMenu data) { the.Add(data); return(data); }