国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

2ge ListBox 之間的 上下選擇,MVC ViewModel

2019-11-17 02:44:38
字體:
來源:轉載
供稿:網友

2ge ListBox 之間的 上下選擇,MVC ViewModel

HtmlCode
 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             else24             {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         }
Function Code
 1 public class RoleViewModel 2     { 3         public string Id { get; set; } 4  5         [Required(ErrorMessage = "'Role' cannot be empty.")] 6         public string Name { get; set; } 7  8         [Required(ErrorMessage = "'Selected Functions' cannot be empty.")] 9         public IList<ActionViewModel> AssignedActions { get; set; }        10         public IList<ActionViewModel> AvailableActions { get; set; }11         public string[] AssignedSelected { get; set; }12         public string[] AvailableSelected { get; set; }13 14         public static RoleViewModel GetFromIcRoles(PortalProj.Common.Entities.IcRoles item, List<IcActions> assignedList, List<IcActions> availableList)15         {16             var role = new RoleViewModel17             {18                 Id = item.RoleId,19                 Name = item.RoleName20             };21 22             role.AssignedActions = new List<ActionViewModel>();23             role.AvailableActions = new List<ActionViewModel>();24 25             if (assignedList != null)26             {27                 foreach (var assigned in assignedList)28                 {29                     var a = new ActionViewModel30                     {31                         Id = assigned.ActionId,32                         Code = assigned.ActionCode,33                         Name =Convert.ToString(assigned.ActionSeq)+ "." + assigned.ActionDesc34                     };35 36                     role.AssignedActions.Add(a);37                 }38             }39 40             if (availableList != null)41             {42                 foreach (var available in availableList)43                 {44                     var a = new ActionViewModel45                     {46                         Id = available.ActionId,47                         Code = available.ActionCode,48                         Name = Convert.ToString(available.ActionSeq) + "." + available.ActionDesc49                     };50 51                     role.AvailableActions.Add(a);52                 }53             }54 55             return role;56         }57 58         public RoleViewModel()59         {60             AssignedActions = new List<ActionViewModel>();61         }62         public void AddAction(ActionViewModel item)63         {64             AssignedActions.Add(item);65         }66     }
ViewModel Code


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 河津市| 城固县| 永济市| 调兵山市| 台中县| 廉江市| 东安县| 锦州市| 色达县| 平乐县| 辽宁省| 天祝| 陆川县| 泰兴市| 平昌县| 汽车| 肥城市| 临桂县| 乌鲁木齐县| 汉阴县| 大丰市| 沈丘县| 临清市| 女性| 定远县| 隆化县| 东兰县| 蓝田县| 威海市| 连山| 铜鼓县| 灵寿县| 浙江省| 雅安市| 吉隆县| 延长县| 罗田县| 宕昌县| 出国| 苍南县| 临湘市|