Top-down selection between 2ge ListBox, MVC ViewModel

Source: Internet
Author: User

HtmlCode
1  PublicRoleviewmodel Generateactionlist (stringRoleid, list<string>assignidlist)2         {3             if(string. IsNullOrEmpty (roleid) && assignidlist = =NULL)4             {5List<icactions> availablelist = This. Servicelocator.getservice<iroleactionservice>(). Getallactions (AppID);6List<icactions> assignlist =NewList<icactions>();7PortalProj.Common.Entities.IcRoles Icroles =NewPortalProj.Common.Entities.IcRoles ();8                 returnroleviewmodel.getfromicroles (Icroles, Assignlist, availablelist);9             }Ten             Else if(string. IsNullOrEmpty (Roleid) && assignidlist! =NULL) One             { AList<icactions> availablelist = This. Servicelocator.getservice<iroleactionservice>(). Getallactions (AppID); -List<icactions> assignlist = This. Servicelocator.getservice<iroleactionservice> (). Getactionbyid (assignidlist). (M =m.actionseq). ToList (); -PortalProj.Common.Entities.IcRoles Icroles =NewPortalProj.Common.Entities.IcRoles (); the                 foreach(varIteminchassignlist) -                 { -                     varItemtoremove = Availablelist.single (i = I.actionid = =item. ActionId); -                     if(Itemtoremove! =NULL) + Availablelist.remove (itemtoremove); -                 } +                 returnroleviewmodel.getfromicroles (Icroles, Assignlist, availablelist); A             } at             Else -             { -PortalProj.Common.Entities.IcRoles Icroles = This. Servicelocator.getservice<iicrolesservice>(). Getrolebyid (Roleid); -List<icactions> availablelist = This. Servicelocator.getservice<iroleactionservice>(). Getallactions (AppID); -List<icactions> assignlist = This. Servicelocator.getservice<iroleactionservice> (). Getactionbyid (assignidlist). (M =m.actionseq). ToList (); -                 foreach(varIteminchassignlist) in                 { -                     varItemtoremove = Availablelist.single (i = I.actionid = =item. ActionId); to                     if(Itemtoremove! =NULL) + Availablelist.remove (itemtoremove); -                 } the                 returnroleviewmodel.getfromicroles (Icroles, Assignlist, availablelist); *             } $}
Function Code
1  Public classRoleviewmodel2     {3          Public stringId {Get;Set; }4 5[Required (errormessage ="' Role ' cannot be empty.")]6          Public stringName {Get;Set; }7 8[Required (errormessage ="' Selected Functions ' cannot be empty.")]9          PublicIlist<actionviewmodel> Assignedactions {Get;Set; } Ten          PublicIlist<actionviewmodel> Availableactions {Get;Set; } One          Public string[] assignedselected {Get;Set; } A          Public string[] availableselected {Get;Set; } -  -          Public StaticRoleviewmodel getfromicroles (PortalProj.Common.Entities.IcRoles item, list<icactions> assignedlist, list< Icactions>availablelist) the         { -             varRole =NewRoleviewmodel -             { -Id =item. Roleid, +Name =item. RoleName -             }; +  ARole. Assignedactions =NewList<actionviewmodel>(); atRole. Availableactions =NewList<actionviewmodel>(); -  -             if(Assignedlist! =NULL) -             { -                 foreach(varAssignedinchassignedlist) -                 { in                     varA =NewActionviewmodel -                     { toId =assigned. ActionId, +Code =assigned. Actioncode, -Name =convert.tostring (assigned. ACTIONSEQ) +"."+assigned. Actiondesc the                     }; *  $ role. Assignedactions.add (a);Panax Notoginseng                 } -             } the  +             if(Availablelist! =NULL) A             { the                 foreach(varAvailableinchavailablelist) +                 { -                     varA =NewActionviewmodel $                     { $Id =available. ActionId, -Code =available. Actioncode, -Name = Convert.ToString (available. ACTIONSEQ) +"."+available. Actiondesc the                     }; - Wuyi role. Availableactions.add (a); the                 } -             } Wu  -             returnrole; About         } $  -          PublicRoleviewmodel () -         { -Assignedactions =NewList<actionviewmodel>(); A         } +          Public voidaddaction (Actionviewmodel Item) the         { - Assignedactions.add (item); $         } the}
ViewModel Code

Top-down selection between 2ge ListBox, MVC ViewModel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.