1 public RoleViewModel generateActionList(string roleId, List<string> assignidlist)
2 {
3 if (string.IsNullOrEmpty(roleId) && assignidlist == null)
4 {
5 List<IcActions> availableList = this.ServiceLocator.GetService<IRoleActionService>().GetAllActions(appid);
6 List<IcActions> assignList = new List<IcActions>();
7 PortalProj.Common.Entities.IcRoles icRoles = new PortalProj.Common.Entities.IcRoles();
8 return RoleViewModel.GetFromIcRoles(icRoles, assignList, availableList);
9 }
10 else if (string.IsNullOrEmpty(roleId) && assignidlist != null)
11 {
12 List<IcActions> availableList = this.ServiceLocator.GetService<IRoleActionService>().GetAllActions(appid);
13 List<IcActions> assignList = this.ServiceLocator.GetService<IRoleActionService>().GetActionById(assignidlist).OrderBy(m => m.ActionSeq).ToList();
14 PortalProj.Common.Entities.IcRoles icRoles = new PortalProj.Common.Entities.IcRoles();
15 foreach (var item in assignList)
16 {
17 var itemToRemove = availableList.Single(i => i.ActionId == item.ActionId);
18 if (itemToRemove != null)
19 availableList.Remove(itemToRemove);
20 }
21 return RoleViewModel.GetFromIcRoles(icRoles, assignList, availableList);
22 }
23 else
24 {
25 PortalProj.Common.Entities.IcRoles icRoles = this.ServiceLocator.GetService<IIcRolesService>().GetRoleById(roleId);
26 List<IcActions> availableList = this.ServiceLocator.GetService<IRoleActionService>().GetAllActions(appid);
27 List<IcActions> assignList = this.ServiceLocator.GetService<IRoleActionService>().GetActionById(assignidlist).OrderBy(m => m.ActionSeq).ToList();
28 foreach (var item in assignList)
29 {
30 var itemToRemove = availableList.Single(i => i.ActionId == item.ActionId);
31 if (itemToRemove != null)
32 availableList.Remove(itemToRemove);
33 }
34 return RoleViewModel.GetFromIcRoles(icRoles, assignList, availableList);
35 }
36 }